Hello World for U
2014-02-19 14:54
323 查看
2012年浙江大学计算机及软件工程研究生机试真题
考察对字符串的操作。
考察对字符串的操作。
#include <stdio.h> #include <string.h> char str[81]; int main(){ int len, n1, n2, n3, i, j, count; while(scanf("%s", str) == 1){ len = strlen(str); n1 = n3 = len / 3; n2 = len - n1 - n3; if(n1 == n2){ --n1; --n3; n2 += 2; } count = 0; for(i = 1; i <= n1; ++i){ for(j = 1; j <= n2; ++j) if(j == 1) putchar(str[count++]); else if(j == n2) putchar(str[len - count]); else putchar(' '); puts(""); } //输出最后一行 for(j = 1; j <= n2; ++j) putchar(str[count++]); puts(""); } return 0; }
相关文章推荐
- SQL Server Reporting Service 报错:报表服务器无法解密用于访问报表服务器数据库中的敏感数据或加密数据的对称密钥,必须还原备份密钥或删除所有加密的内容。
- Android应用程序注册广播接收器(registerReceiver)的过程分析
- 深入浅出正则表达式及grep,egrep异同解析
- table中的colspan和rowspan
- 浅谈线段树 Segment Tree
- 再回首UML之上篇
- UIColor,CGColor,CIColor三者的区别和联系
- 在C语言中解析json配置文件
- PreferenceActivity中添加自定义布局文件需要注意的地方
- 产品设计原型制作工具【mark】
- 网络连接错误代码大全及处理办法
- 再回首UML之上篇
- org.hibernate.MappingException: duplicate import异常
- DevExpress.XtraEditors.TextEdit 设为密码输入框
- 设计之下——搜狐新闻客户端的用户体验设计(全彩)
- 打包ios程序成ipa
- xcode和苹果系统OS 一些常用的快捷键
- 自动机学习简单的总结
- 自动机学习简单的总结
- JAVA编程中在性能优化方面需要注意的地方