uva 10361 - Automatic Poetry
字符串处理,不过做的有点麻烦

1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int n,i,j,k,x,len1,len2,count,y; 6 char str1[1000],str2[1000],str[1000]; 7 scanf("%d",&n); 8 getchar(); 9 while(n--) 10 { 11 gets(str1); 12 gets(str2); 13 len1=strlen(str1); 14 len2=strlen(str2); 15 count=0; 16 for(i=0;i<len1;i++) 17 { 18 19 if(str1[i]!='<'&&str1[i]!='>') 20 { 21 printf("%c",str1[i]); 22 } 23 else 24 { 25 if(count==0&&str1[i]=='<') 26 { 27 y=i; 28 } 29 count++; 30 } 31 } 32 printf("\n"); 33 k=0; 34 count=0; 35 for(i=len1-1;i>=0;) 36 { 37 if(str1[i]=='>') 38 { 39 count++; 40 if(count==1) 41 x=i; 42 while(str1[i]!='<') 43 { 44 i--; 45 } 46 47 j=i+1; 48 49 while(str1[j]!='>') 50 { 51 str[k]=str1[j]; 52 k++; 53 j++; 54 } 55 if(i>y) 56 { 57 while(str1[i]!='>') 58 { 59 i--; 60 } 61 j=i+1; 62 while(str1[j]!='<') 63 { 64 str[k]=str1[j]; 65 k++; 66 j++; 67 } 68 } 69 else 70 break; 71 } 72 else 73 i--; 74 } 75 for(x+=1;x<len1;x++) 76 { 77 str[k]=str1[x]; 78 k++; 79 } 80 for(i=0;i<len2;) 81 { 82 83 if(str2[i]=='.'&&str2[i+1]=='.'&&str2[i+2]=='.') 84 { 85 for(j=0;j<k;j++) 86 printf("%c",str[j]); 87 i+=3; 88 } 89 else{ 90 printf("%c",str2[i]); 91 i++; 92 } 93 94 } 95 printf("\n"); 96 97 } 98 return 0; 99 }
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· 一次Java后端服务间歇性响应慢的问题排查记录
· 互联网不景气了那就玩玩嵌入式吧,用纯.NET开发并制作一个智能桌面机器人(四):结合BotSharp
· Vite CVE-2025-30208 安全漏洞
· 《HelloGitHub》第 108 期
· MQ 如何保证数据一致性?
· 一个基于 .NET 开源免费的异地组网和内网穿透工具