zoukankan      html  css  js  c++  java
  • UVA 10361 Automatic Poetry

    题目要求非常easy,给两个字符串,第一个字符串中有'<'和‘>’的符号。整个字符串能够分为s1<s2>s3<s4>s5。

    第二个字符串中结尾是'...'。要求输出两个字符串,一个是将第一个字符串中的'<'和'>'去掉,还有一个是在第二个字符串后面加上s4s3s2s5。直接模拟就可以。

    #include<stdio.h>
    #include<string.h>
    #include<iostream>
    #include<algorithm>
    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;
    }


  • 相关阅读:
    Binary search tree
    搜索二叉树
    windows最基本命令行
    sublime package
    二叉树的层次遍历和其深度
    二叉树后序遍历
    PopupWindow的使用
    android之ViewPager的使用
    android部分开发摘要
    android4.0以后要求网络请求必须发生在子线程中
  • 原文地址:https://www.cnblogs.com/zsychanpin/p/7066883.html
Copyright © 2011-2022 走看看