当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
信息系统项目的十大管理
PTA习题 分类统计字符个数(C)
【C language】动态数组的创建和使用
PTA 实验7-5 输出大写英文字母(10 分)
MATLAB中如何把cftool拟合的函数输出到命令行(解决如何导出拟合后的曲线数据)
图片查看器viewer
Preparation for gold three silver four: how to successfully get an Ali offer (experience + interview questions + how to prepare)
ICML 2022 | Out-of-Distribution Detection with Deep Nearest Neighbors
Error: Cannot find module ‘./application‘
去除蜂窝状的噪声(matlab实现)
随机推荐
golang 三种指针类型具体类型的指针、unsafe.Pointer、uintptr作用
PTA 计算天数
综述文章的写法
x86 Exception Handling and Interrupt Mechanism (1) Overview of the source and handling of interrupts
最长回文子串
使用.NET简单实现一个Redis的高性能克隆版(四、五)
从位图到布隆过滤器
学习阶段总结(背包问题)
electron 应用开发优秀实践
MATLAB代码实现三次样条插值
信息系统项目的十大管理
∘(空心的点乘)的数学含义
[C language] creation and use of dynamic arrays
Julia常见符号意思
OC-NSTimer
依赖注入(Dependency Injection)框架是如何实现的
PTA习题 分类统计字符个数(C)
caffe ---make all editing error
Quartz的理解
杂记(6)