题解 | #添加逗号#
添加逗号
https://www.nowcoder.com/practice/f51c317e745649c0900996fd3f683aed
#include <stdio.h>
#include<string.h>
#define NUM 2000000
int main()
{
char str[NUM] = { 0 };
//输入
while (~scanf("%s", str))
{
int len = strlen(str);
int cnt = len;//计数器
//输出
for (int i = 0; i < len; i++, cnt--)
{
if (cnt % 3 == 0 && cnt != len)
{
printf(",");
}
printf("%c", str[i]);
}
}
return 0;
}
查看29道真题和解析