1108 Finding Average】的更多相关文章

1108 Finding Average (20 分) The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A legal input is a real number in [−1000,1000…
1108 Finding Average (20 分) The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A legal input is a real number in [−1000,1000…
1108 Finding Average(20 分) The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A legal input is a real number in [−1000,1000]…
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<queue> #include<stack> #include<algorithm> using namespace std; ]; int n; int num,num2,pos; bool f() { ; ;s[i]…
求给出数的平均数,当然有些是不符合格式的,要输出该数不是合法的. 这里我写了函数来判断是否符合题目要求的数字,有点麻烦. #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> using namespace std; ; bool islegal(char*str){ int len=strlen(str); ,; ;i<len;i++){ //if…
题意:根据条件判定哪些数是合法的,哪些是不合法的.求其中合法的数的平均值. 思路:字符串处理函数,考虑到最后输出的时候需要控制格式,因此选用scanf()和printf().另外需要了解atof()函数,用的较多的是atoi(),但这里是浮点数的转换,所以不要搞错了.(两者都在头文件<stdlib.h>下) 代码: #include <cstdio> #include <cstring> #include <cstdlib>//atof() #include…
The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A legal input is a real number in [−1000,1000] and is accurate up to no m…
The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A legal input is a real number in [−] and is accurate up to no more than…
题意: 输入一个正整数N(<=100),接着输入一行N组字符串,表示一个数字,如果这个数字大于1000或者小于1000或者小数点后超过两位或者压根不是数字均为非法,计算合法数字的平均数. trick: 测试点2答案错误原因:题面指出如果只有一个合法数字,输出numbers的时候不加s,即为number. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std;…
The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A legal input is a real number in [−1000,1000] and is accurate up to no m…