设为首页 加入收藏

TOP

UVA 10361 Automatic Poetry
2015-11-21 00:57:47 来源: 作者: 【 】 浏览:2
Tags:UVA 10361 Automatic Poetry

题目要求很简单,给两个字符串,第一个字符串中有'<'和‘>’的符号,整个字符串可以分为s1 s3 s5。第二个字符串中结尾是'...'。要求输出两个字符串,一个是将第一个字符串中的'<'和'>'去掉,另一个是在第二个字符串后面加上s4s3s2s5。直接模拟即可。

?

#include
  
   
#include
   
     #include
    
      #include
     
       using namespace std; int main() { int n,l1,l2,i,j,k,f; char str1[105],str2[105],c,s2[105],s3[105],s4[105],s5[105]; scanf(%d,&n); getchar(); while(n--) { i=j=0; f=0; while((c=getchar())!=' ') { if(c=='<'&&f==0){f=1;j=0;continue;} if(c=='>'&&f==1){f=2;s2[j]='';j=0;continue;} if(c=='<'&&f==2){f=3;s3[j]='';j=0;continue;} if(c=='>'&&f==3){f=4;s4[j]='';j=0;continue;} str1[i++]=c; if(f==1)s2[j++]=str1[i-1]; if(f==2)s3[j++]=str1[i-1]; if(f==3)s4[j++]=str1[i-1]; if(f==4)s5[j++]=str1[i-1]; } s5[j]=str1[i]=''; i=0; while((c=getchar())!=' ') { if(c!='.')str2[i++]=c; } str2[i]=''; printf(%s ,str1); printf(%s%s%s%s%s ,str2,s4,s3,s2,s5); } return 0; }
     
    
   
  


?

?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇LeetCode―Median of Two Sorted.. 下一篇Leetcode : Regular Expression M..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: