A1060 Are They Equal (25 分)】的更多相关文章

一.技术总结 cnta.cntb用于记录小数点出现的位置下标,初始化为strlen(字符串)长度. q.p用于记录第一个非0(非小数点)出现的下标,可以用于计算次方和方便统计输出的字符串,考虑到前面可能出现0. 如果cnta > p ,说明小数点在第一个开始的非0数的下标的右边,那么科学计数法的指数为cnta – p ; 否则应该为cnta – p + 1; 字符串b同理 如果字符串p.q等于字符串长度,说明字符串为0,此时直接把 cnta(或者cntb)置为0,因为对于 0来说乘以几次方都是相…
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…
题意: 输入一个正整数N(<=100),接着输入两个浮点数(可能包含前导零,对于PAT已经习惯以string输入了,这点未知),在保留N位有效数字的同时判断两个数是否相等,并以科学计数法输出. trick: 测试点3含有有效数字在小数点以后的数据,此时指数应该是小数点位置减有效数字位置再加上1. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; stri…
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…
1043 Is It a Binary Search Tree(25 分) A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a nod…
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…
A1055 The World's Richest(25 分) Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the people in a certain ran…
1055 The World's Richest (25 分) Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the people in a certain ran…