#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main()
{
char str[80];
int n,i=0,t;
gets(str);
scanf("%d",&n);
t=strlen(str);//判断字符长度
while(i<t)//进行循环
{
if(n>0)//n的大小然后输出
printf("%c",str[i]);
if(n==0)
puts(str);
if((i+1)%n==0)//n个一循环
printf("\n");
i++;
}
return 0;
}
王朝 第十六周 字符格式输出
字符处理与输出
最新推荐文章于 2024-08-02 16:57:45 发布
本文介绍了一个简单的C语言程序,该程序通过用户输入的字符串和整数来控制字符的输出方式。程序首先读取一个字符串,然后接收一个整数n,根据n的值决定如何输出这些字符,包括逐个字符输出、按n个字符一组换行等。
1180

被折叠的 条评论
为什么被折叠?



