当前位置:网站首页>PAT1001
PAT1001
2022-08-09 11:09:00 【AlanLiu6】
https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400
好久没刷过题了,手感十分生疏,以前的都忘光了,先刷刷题试试手感
#include<cstdio>
#include<cstring>
#include<stdlib.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
// printf("%d %d",a,b);
int c = a+b;
char str[100];
// itoa(c,str,10);
/*
itoa函数功能详解
itoa(c,str,10)
三个输入的意思为 :
第一个 要转化的整数
第二个 要存入的字符串
第三个 转换后的进制位 这里为10进制
*/
sprintf(str,"%d",c);
/*
sprintf 功能详解
sprintf(str,"%d%f%s",a,b,c);
即先不看 str的内容,将此函数视为printf输出按格式abc,
这里只是将输出的abc存到了str中
*/
// printf("%s --- %d\n",str,strlen(str));
char ans[16] = " ";
int flag =0;
for(int i = strlen(str)-1,j = 0;i >=0;i--,j++)
{
// printf("i: %d ans:%d\n",i,strlen(ans));
if(flag ==3 && str[i]!= '-')
{
ans[j] = ',';
j++;
flag =0;
}
ans[j] = str[i];
flag++;
}
for(int i = strlen(ans)-1;i>=0;i--)
printf("%c",ans[i]);
printf("\n");
return 0;
}
边栏推荐
猜你喜欢
随机推荐
Preparation for gold three silver four: how to successfully get an Ali offer (experience + interview questions + how to prepare)
Qt获取EXE可执行文件的上一级目录下的文件
排序--快排(图解)
Use gdb to debug multi-process programs, debug parent and child processes at the same time
MySQL传统方案和通过SSH连接哪个好?
PTA 找出不是两个数组共有的元素
The use of gdb tui
【精华文】C语言结构体特殊情况分析:结构体指针 / 基本数据类型指针,指向其他结构体
x86异常处理与中断机制(3)中断处理过程
性能测试(04)-表达式和业务关联-JDBC关联
【VIBE: Video Inference for Human Body Pose and Shape Estimation】论文阅读
从位图到布隆过滤器
STemwin中GUI_Exec和GUI_Delay
es6递归函数
Open3D 点云平均点间距评估
微信小程序——天气查询
Missing URI template variable ‘employeeNumber‘ for method parameter of type String
剖析STM32F103时钟系统
通关SQLilab靶场——Less-1思路步骤
es6的async函数