poj-1528
来源:互联网 发布:现货黄金分时买卖源码 编辑:程序博客网 时间:2024/06/05 19:06
题目不难,主要注意输出格式即可。
#include <iostream>#include <cstdio>//有此头文件才可以用printf输出方式。 #include<iomanip>//包含cout输出格式的头文件 using namespace std;int main(){ int i,n,a[120]; printf("PERFECTION OUTPUT\n"); while(scanf("%d",&n)) { int sum=0; if(n==0) { cout<<"END OF OUTPUT"<<endl; break;//n为0跳出循环 } if(n==1) { printf("%5d DEFICIENT\n",n); continue;//继续输入,直到输入为0为止 } for(i=1;i<n;i++) if(n%i==0) sum+=i; if(sum<n) <span style="white-space:pre"></span>printf("%5d DEFICIENT\n",n);//因为printf控制输出格式比较方便,所以一般不用cout,直接定义头文件#include<cstdio> /* { cout<<setw(5)<<n<<" "; cout<<"DEFICIENT"<<endl; 这两行语句和上面的printf效果一样 }*/else if(sum==n) printf("%5d PERFECT\n",n);//前5位相应的整数向右对齐,只要确保所有整数输出5位即可 else printf("%5d ABUNDANT\n",n); } return 0;}
0 0
- 【POJ】:POJ 1528Perfection
- POJ 1528
- POJ 1528
- POJ-1528
- poj-1528
- poj 1528 Perfection
- poj 1528 Perfection
- poj 1528 Perfection
- POJ 1528 perfection
- POJ 1528 Perfection
- POJ 1528因子之和
- POJ-1528-Perfection
- poj 1528 Perfection
- POJ 1528 Perfection 模拟
- poj 1528 perfection
- POJ 1528 Perfection
- poj 1528 Perfection
- POJ 1528 Perfection
- 华为OJ基础篇-查找输入整数二进制中1的个数
- 1098. Insertion or Heap Sort (25)
- 天声人語 20151122 北の湖理事長の急死
- Core Data基础概念总结
- 字母检测
- poj-1528
- 对数组进行升序和降序排序
- wamp服务器——httpd.exe不能正常工作,0xc000007b应用程序错误
- springMVC配置文件
- Android开发手记(7) 按钮类控件的使用
- char* strlen()学习
- 3.11 三维柱形图
- C++IO流简介
- Core Data浅谈系列之一 : 基础结构