这道题目的意思是先给你一些字符为key[i],然后在遇到::时候终止,然后给你一些字符串,str[i]。
在这些字符串中的每一个单词如果与给定的所有的key不一样,就作为key_know,然后对key_know排序,最后输出排序后,key_know所在的字符串,并且除了key_know
是大写的之外,其他的都是小写的。#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{int i,j,q,leap,number_ti,T,key_number,n,w;int num[1000],dan_num[1000];char key[205][52];char key_get[52];char str[205][52];char strr[52];char key_know[205][52];leap=0;while(scanf("%s",key[leap])){if(strlen(key[leap])==2){if(key[leap][0]==':'&&key[leap][1]==':'){leap++;break;}}leap++;}getchar();key_number=leap;leap=0;T=0;while(gets(str[T])!=NULL){T++;n=strlen(str[T-1]);q=-1;w=0;for(i=0;i<n;i++){if(str[T-1][i]>='A'&&str[T-1][i]<='Z')str[T-1][i]+='a'-'A';}for(i=0;i<n;i++){q++;key_get[q]=str[T-1][i];if(str[T-1][i]==' '||i==n-1){w++;if(i==n-1)q++;key_get[q]='\0';q=-1;for(j=0;j<key_number;j++){if(strcmp(key_get,key[j])==0)break;}if(j==key_number){strcpy(key_know[leap],key_get);num[leap]=T-1;dan_num[leap]=w;leap++;}}}}for(i=0;i<leap;i++){for(j=i;j<leap;j++){if(strcmp(key_know[i],key_know[j])>0||(strcmp(key_know[i],key_know[j])==0&&num[i]>num[j])){strcpy(strr,key_know[i]);strcpy(key_know[i],key_know[j]);strcpy(key_know[j],strr);number_ti=num[i];num[i]=num[j];num[j]=number_ti;number_ti=dan_num[i];dan_num[i]=dan_num[j];dan_num[j]=number_ti;}}}for(i=0;i<leap;i++){w=1;for(j=0;j<strlen(str[num[i]]);j++){if(w!=dan_num[i]){printf("%c",str[num[i]][j]);}else{if(str[num[i]][j]!=' ')printf("%c",str[num[i]][j]+'A'-'a');elseprintf(" ");}if(str[num[i]][j]==' ')w++;}printf("\n");}return 0;
}
详细解决方案
uva-123 - Searching Quickly
热度:94 发布时间:2023-12-19 11:43:03.0
相关解决方案
- 四、Fixing Common Problems Quickly with Camera Raw
- 起步eclipse是报 no java virtual machine was found after searching the following location
- [论文解读]arXiv 219|MobileNetV3: Searching for MobileNetV3
- React Quickly 免积分下载
- (交互题)Searching Local Minimum
- g++编译问题:skipping incompatible /usr/lib//libboost_system.so when searching for -lboost_system
- uva 1597 Searching the Web (wrong)
- Codeforces Round #371 (Div. 2)D. Searching Rectangles交互题
- AC自动机 zoj3228 Searching the String
- Solr Multicore 结合 Solr Distributed Searching 切分大索引来搜索
- uva-123 - Searching Quickly
- matlab win7 运行 窗口 一闪 消失 window disappear quickly
- Searching and Mining Trillions of Time Series ubsequences under Dynamic Time Warping论文笔记
- 随机搜索(Random Searching)算法
- 随机搜索(Random Searching)算法概述
- Open Baidu webpage and type in Chinese characters to start searching, press “Back” button to go to B
- Searching for MobileNetV3
- Thinking...!thinking life,think how to improve myself ablity quickly!
- No java virtual machine was found after searching the follwing locations
- Supervisor大坑【已解决】:Exited too quickly (process log may have details)