PAT 1108
来源:互联网 发布:mysql 导出表命令 编辑:程序博客网 时间:2024/06/11 21:17
#include<cstdio>#include<iostream>#include<string>#include<string.h>#include<algorithm>using namespace std;int main(){char a[50],b[50];int n;cin>>n;bool flag;double temp,average=0.0;int cnt=0;for(int i=0;i<n;i++){flag=true;scanf("%s",a);sscanf(a,"%lf",&temp);sprintf(b,"%.2lf",temp);for(int j=0;j<strlen(a);j++){if(a[j]!=b[j])flag=false;}if(flag&&temp>=-1000&&temp<=1000){average+=temp;cnt++;}else{printf("ERROR: %s is not a legal number\n",a);}}if(cnt==0)printf("The average of 0 numbers is Undefined");elseaverage/=cnt;if(cnt==1) printf("The average of %d number is %.2lf",cnt,average);if(cnt>1) printf("The average of %d numbers is %.2lf",cnt,average);system("pause");return 0;}
0 0
- PAT 1108
- PAT 1108
- PAT-A:1108
- *浙大PAT甲级 1108
- PAT甲级1108
- PAT 1108 Finding Average
- pat
- 【PAT】
- PAT
- PAT
- PAT
- PAT
- PAT
- PAT
- PAT
- PAT
- PAT
- pat
- gdb调试手册
- 英文分词算法(Porter stemmer)
- win32数字时钟
- CamWorks 铣削曲面
- Tomcat web.xml配置详解
- PAT 1108
- 图的深搜练习-2
- HQL查询——查询返回对象类型分析
- 离散数学学习总结
- linux内核分析:进程切换机制
- Windows程序 如何实现程序重启
- 69.Sqrt(x)
- hihocoder 第139周
- 开源分布式文件系统比较