PAT 1001. A+B Format(水题)
#include<cstdio>
#include<cstring>
using namespace std; char s[10]; int main()
{
int a,b;
while(scanf("%d%d",&a,&b)==2)
{
memset(s,0,sizeof(s));
a=a+b;
if(a==0)
{
printf("0\n");
continue;
}
int aa=a;
b=0;
if(a<0)
{
a=-a;
}
while(a)
{
int r=a%10;
s[b++]=('0'+r);
a=a/10;
}
if(aa<0)
{
printf("-"); }
for(int i=b-1; i>=0; i--)
{
if(i==0)
printf("%c\n",s[i]);
else
printf("%c",s[i]);
if(i%3==0&&i!=0)
printf(",");
} }
return 0;
}
PAT 1001. A+B Format(水题)的更多相关文章
- PAT 1001. A+B Format 解题
GitHub PDF 1001. A+B Format (20) Calculate a + b and output the sum in standard format -- that is, t ...
- 2014百度之星资格赛 1001:Energy Conversion(水题,逻辑题)
Energy Conversion Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- pat 1001 A+B Format
题目链接:传送门 题目简述: 1. 给定两个整数值a,b: 2.范围-1000000 <= a, b <= 1000000: 3.按指定格式输出结果 例:-100000 9 输出: -99 ...
- PAT 1001 A+B Format (20分) to_string()
题目 Calculate a+b and output the sum in standard format -- that is, the digits must be separated into ...
- caioj 1001: [视频]实数运算1[水题]
题意:输入两个实数a和b,输出它们的和 题解:简单题不写题解了-- 代码: #include <cstdio> double a, b; int main() { while (~scan ...
- URAL 1001 Reverse Root(水题?)
The problem is so easy, that the authors were lazy to write a statement for it! Input The input stre ...
- PAT 1001 A+B Format (20 point(s))
题目: 我一开始的思路是: 用math.h中的log10函数来计算位数(不建议这么做,因为会很慢,而且会出一点别的问题): 用pow函数根据要插入分号的位置来拆分a+b成一个个数字(例如res / p ...
- PAT甲 1001. A+B Format (20) 2016-09-09 22:47 25人阅读 评论(0) 收藏
1001. A+B Format (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Calculate ...
- 1001 字符串“水”题(二进制,map,哈希)
1001: 字符串“水”题 时间限制: 1 Sec 内存限制: 128 MB提交: 210 解决: 39[提交][状态][讨论版] 题目描述 给出一个长度为 n 的字符串(1<=n<= ...
随机推荐
- vue.js 2的表单控件
静下心,抄一段sample,以后可以快点到这里来抄...: <!DOCTYPE html> <html> <head> <meta charset=" ...
- Nginx模块GeoIP匹配处理IP所在国家、城市
https://www.haiyun.me/archives/nginx-geoip.html
- 我在16ASPX下了一个系统是ACCESS和VS2005做的我想把那个连接数据库的'DB_16aspx'的名字改了进不了了可是?
靠,在web.config或者其他配置文件中把数据库连接字符串改称你的新名字不就行了
- SpringMVC + Hibernate + MySQL 的简易网页搭建(Dao层 实现篇)
首先在搭建一个网站后台前,需要明确出一个合理的网页搭建的结构框架,即从DB ==> Dao层 ==>Service层 ==>Control层 ==>View层(该层严格意义 ...
- 推荐一个国内的免费公共静态cdn
https://cdn.baomitu.com/ 更新速度比bootcdn要快,收录的库也很齐全.
- springboot引入thymeleaf
springboot引入thymeleaf 1.Thymeleaf使用 @ConfigurationProperties(prefix = "spring.thymeleaf") ...
- python 字符串最长公共前缀
编写一个函数来查找字符串数组中的最长公共前缀. 如果不存在公共前缀,返回空字符串 "". 示例 1: 输入: ["flower","flow&qu ...
- IO模型同步与异步阻塞与非阻塞的区别
同步异步的区别 关注点:同步和异步关注的是消息通信机制 同步:所谓同步,就是在发出一个*调用*时,在没有得到结果之前,该*调用*就不返回.但是一旦调用返回,就得到返回值了.换句话说,就是由*调用者*主 ...
- iOS禁止多点操作(按钮和Table项)
1)避免同时点击多个按钮: [btn setExclusiveTouch:YES]; 设置确保当btn点击时,其他按钮不响应: (2)避免同时点击UITableView中多个row -(NSIndex ...
- 线程同步-CountDownLatch
应用场景: 有一个任务想要往下执行,但必须要等到其他的任务执行完毕后才可以继续往下执行. 假如我们这个想要继续往下执行的任务调用一个CountDownLatch对象的await()方法,其他的任务执行 ...