UVa 490 - Rotating Sentences
来源:互联网 发布:720p网络摄像头 编辑:程序博客网 时间:2024/06/11 15:12
13522363490Rotating SentencesAcceptedANSI C0.0092014-04-20 13:34:51【问题描述】
将字符串顺时针旋转90度输出
【解决过程】
一开始以为不用补空格,于是WA,
然后以为是最后不能换行,改后WA,
最后才知道是数组越界:100个字符加上换行符一共101个字符……最后,代码如下:
#include<stdio.h>#include<string.h>#define MAXN 100+10char s[MAXN][MAXN];int main(){int n=0,i,j,maxl=0;memset(s,' ',sizeof(s)); while(fgets(s[n++],MAXN,stdin))if(strlen(s[n-1])>maxl) maxl=strlen(s[n-1]);for(i=0;i<maxl-1;i++){for(j=1;j<n;j++)if(i<strlen(s[n-1-j])-1)printf("%c",s[n-1-j][i]);elseprintf(" ");printf("\n");}return 0;}【教训】
1、不要简单把自己以为的边界当做边界
2、strlen会把换行符算进去
3、字符串题目(尤其是对格式要求很严格的)最好用文件输出差错,提交时不忘删去文件部分
4、ANSI C中注释不能用//
0 0
- Uva 490 Rotating Sentences
- UVa 490 - Rotating Sentences
- UVA-490-Rotating Sentences
- UVa 490 - Rotating Sentences
- UVA 490 - Rotating Sentences
- UVa 490 - Rotating Sentences
- UVa:490 - Rotating Sentences
- UVA 490 Rotating Sentences
- UVA:490 - Rotating Sentences
- UVA - 490 - Rotating Sentences
- UVa 490 - Rotating Sentences
- UVa 490 - Rotating Sentences
- UVa 490 Rotating sentences
- UVA - 490 Rotating Sentences
- UVA 490 Rotating Sentences
- UVA - 490 Rotating Sentences
- UVa 490 - Rotating Sentences
- UVA 490 Rotating Sentences
- 韩剧
- MyEclipse10破解
- ArchLinux国内源&pacman常用命令
- 数据结构-Astar算法-最短路径
- 上古天真论
- UVa 490 - Rotating Sentences
- CodeForces 24B F1 Champions (简单题)
- 北大OJ百练——3179:最长单词(C语言)
- apue和unp的学习之旅08——I/O复用
- [2011山东省第二届ACM大学生程序设计竞赛]——Mathman Bank
- SMB
- OpenCV读取视频文件返回NULL原因
- 楼房的舒服哈市的法律进来撒回复看点啥富士达是打发撒旦法撒旦
- 23.基于 邻接表 dfs 的 求连通分支