1001. A+B Format (20)
来源:互联网 发布:企业成本核算软件 编辑:程序博客网 时间:2024/06/05 20:12
之前账号丢失,重新刷一下PAT,迎接PAT考试。
这是一个非常水的题目,但是因为好久没有写C++,一开始导致不知道如何写起,还是按照以前的习惯来写的,一年发现自己没什么进步,以后要多拜读一下大神的code
代码如下:
#include<iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
{
int sum = 0;
int s[10];
int i = 0;
sum = a+b;
if(sum<0)
{
cout<<"-";
sum = -sum;
}
if(sum == 0)
cout<<0;
while(sum!=0)
{
s[i++] = sum%10;
sum/=10;
}
for(int j=i-1;j>=0;j--)
{
cout<<s[j];
if(j!=0&&j%3==0)
cout<<",";
}
cout<<endl;
}
return 0;
}
太简单,不记录思想了,也没有任何算法。
0 0
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 电信141p51第20题
- Ubuntu 14.10下为firefox和chromium安装flash
- Android六大类进程介绍
- 有关输出对齐格式
- android-四种基本布局
- 1001. A+B Format (20)
- Hibernate学习总结
- python使用正则表达式编写网页小爬虫
- C++:const_cast类型转换
- 多python随机数函数的分析
- 天池大数据竞赛——UI特征统计
- 注意:C语言中没有指定同一运算符的多个操作数或者某函数各个参数的求值顺序,如果代码的执行结果和求值顺序有关,都是不好的程序设计风格。
- nyoj-1055-小鱼儿的难题
- Activity跳转Flag详解