poj 1750
来源:互联网 发布:网络上课平台教师招聘 编辑:程序博客网 时间:2024/05/21 10:48
题目很绕,看懂题目给出的测试用例不难,但是注意细节就不是那么简单的事情了,特别是这类字符串处理的题目。注意题目里面有一个隐藏的问题,如果是出现多个相同的单词怎么办?
应该是这样的效果:
下面出AC的代码:
#include<stdio.h>#include<string.h>char lastWord[100],nowWord[100];int main(){freopen("in.txt", "r", stdin);int spaceNum=0,SameNum=0;int i;scanf("%s",lastWord);printf("%s\n",lastWord);while(scanf("%s",nowWord)!=EOF){for(i=0;i<strlen(lastWord) && i<strlen(nowWord);i++){if(lastWord[i]!=nowWord[i])break;}//printf("i == %d\n",i);if (i>SameNum)spaceNum++;elsespaceNum=i;SameNum=spaceNum;for(i=0;i<spaceNum;i++)putchar(' ');printf("%s\n",nowWord);strcpy(lastWord,nowWord);}return 0;}
0 0
- poj 1750
- poj 1750
- POJ-1750
- POJ 1750 Dictionary
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- POJ
- POJ
- ZCup后继有“赛”,OCup再度激发魔兽3热情
- poj 2155 二维树状数组
- unity3D游戏开发七之创建基本游戏场景四
- MD5加密工具
- Struts2 configuration: Action Config[笔记]
- poj 1750
- 如果文件不存在,创建该文件
- 随机数
- unity3D游戏开发八之天空盒
- 一些字体的资源留存
- 分类算法-----KNN
- iOS:UITableViewCell 方法 属性 详解
- unity3D游戏开发九之雾效、水效和音效
- C语言中volatile关键字的作用