当前位置:网站首页>L1-039 古风排版(C)
L1-039 古风排版(C)
2022-08-02 03:22:00 【寒江飞冰】
中国的古人写文字,是从右向左竖向排版的。本题就请你编写程序,把一段文字按古风排版。
输入格式:
输入在第一行给出一个正整数N(<100),是每一列的字符数。第二行给出一个长度不超过1000的非空字符串,以回车结束。
输出格式:
按古风格式排版给定的字符串,每列N个字符(除了最后一列可能不足N个)。
输入样例:
4
This is a test case
输出样例:
asa T
st ih
e tsi
ce s
代码如下:
#include<stdio.h>
#include<string.h>
char a[100][10001];
char b[1001];
int main()
{
int n;
scanf("%d",&n);
getchar();
int t=0;
int i,j;
char c;
while((c=getchar())!='\n')
{
b[t++]=c;
}
int m=(t+n-1)/n;
int f=0;
for(j=m-1;j>=0;j--)
{
for(i=0;i<n;i++)
{
if(f<t)
a[i][j]=b[f++];
else
a[i][j]=' ';
}
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
printf("%c",a[i][j]);
}
printf("\n");
}
}
边栏推荐
猜你喜欢
[email protected]在static属性上的使用"/>
@Autowired详解[email protected]在static属性上的使用
如何查看一个现有的keil工程之前由什么版本的keil IDE编译
Deveco studio 鸿蒙app访问网络详细过程(js)
客户评分控件
subprocess.CalledProcessError: Command 'pip install 'thop'' returned non-zero exit status 1.
mysql阶段总结
Source Insight 使用教程(2)——常用功能
语义分割标签即像素值的巨坑,transforms.ToTensor()的错误使用
啃瓜记录第一天
Error in render: “TypeError: Cannot read properties of null (reading ‘0‘)“ 报错解决方案
随机推荐
Phospholipid-polyethylene glycol-thiol, DSPE-PEG-Thiol, DSPE-PEG-SH, MW: 5000
页面加载流程
PCL—point cloud data segmentation
猴子选大王
Knowledge Engineering Assignment 2: Introduction to Knowledge Engineering Related Fields
cross-domain problem solving
C语言 十六进制整数字符串转十进制整数
UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the index ing argu
STM32 map文件解析
URL模块
DSPE-PEG-PDP, DSPE-PEG-OPSS, phospholipid-polyethylene glycol-mercaptopyridine supply, MW: 5000
np.isnan()
MySQL中字符串比较大小(日期字符串比较问题)
PCL—点云数据分割
【装机】老毛桃的安装及使用
Scientific research reagent DMPE-PEG-Mal dimyristoylphosphatidylethanolamine-polyethylene glycol-maleimide
mysql阶段总结
basic operator
Phospholipid-Polyethylene Glycol-Aldehyde DSPE-PEG-Aldehyde DSPE-PEG-CHO MW: 5000
COCO数据集训练TPH-YoloV5