pat 1060. Are They Equal (25)】的更多相关文章

题目意思直接,要求将两个数转为科学计数法表示,然后比较是否相同  不过有精度要求 /* test 6 3 0.00 00.00 test 3 3 0.1 0.001 0.001=0.1*10^-2 pay 前导0 不同格式的0 */ #include<iostream> #include<stdio.h> #include<string.h> using namespace std; char a[105],b[105]; struct num { char s[105…
1060 Are They Equal (25)(25 分) If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123*10^5^ with simple chopping. Now given the number of significant digits on a ma…
1060 Are They Equal (25 分)   If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0 with simple chopping. Now given the number of significant digits on a machine and tw…
1060 Are They Equal (25 分)   If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×10​5​​ with simple chopping. Now given the number of significant digits on a mac…
1060 Are They Equal (25分) 题目 思路 定义结构体 struct fraction{ string f; int index; } 把输入的两个数先都转换为科学计数法,统一标准后再做比较,index表示指数 注意点 0或者0的各种形式 0.1, 0.01等 代码 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vect…
1060 Are They Equal(25 分) If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×10​5​​ with simple chopping. Now given the number of significant digits on a machin…
1060 爱丁顿数(25 分) 英国天文学家爱丁顿很喜欢骑车.据说他为了炫耀自己的骑车功力,还定义了一个"爱丁顿数" E ,即满足有 E 天骑车超过 E 英里的最大整数 E.据说爱丁顿自己的 E 等于87. 现给定某人 N 天的骑车距离,请你算出对应的爱丁顿数 E(≤N). 输入格式: 输入第一行给出一个正整数 N (≤10​5​​),即连续骑车的天数:第二行给出 N 个非负整数,代表每天的骑车距离. 输出格式: 在一行中给出 N 天的爱丁顿数. 输入样例: 10 6 7 6 9 3…
题意: 输入一个正整数N(<=100),接着输入两个浮点数(可能包含前导零,对于PAT已经习惯以string输入了,这点未知),在保留N位有效数字的同时判断两个数是否相等,并以科学计数法输出. trick: 测试点3含有有效数字在小数点以后的数据,此时指数应该是小数点位置减有效数字位置再加上1. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; stri…
模拟题.坑点较多. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> #include<map> #include<queue> #include<string> #include<stack> #include<vector> using namespace…
又是一道字符串处理的题目... 题意:给出两个浮点数,询问它们保留n位小数的科学计数法(0.xxx*10^x)是否相等.根据是和否输出相应答案. 思路:先分别将两个浮点数转换成相应的科学计数法的格式1.point为小数点的索引,初始化为字符串的长度len2.not0位第一个非0的数字的索引,初始化为len如果not0为len,表明该浮点数为0,特殊处理,形式为0.0..0*10^0否则根据point和not0的大小,计算相应的指数.接着便是从str的not0开始,给ans赋值,共n位不包括小数点…