白书练习 字母重排
来源:互联网 发布:沥青混合料油石比数据 编辑:程序博客网 时间:2024/05/16 11:56
输入:
tarp given score refund only trap work earn course pepper part *******
resco nfudre aptr sett oresuc
输出:
score
refund
part tarp trap
:(
course
//// main.cpp// 字母重排//// Created by 张嘉韬 on 16/1/29.// Copyright © 2016年 张嘉韬. All rights reserved.//#include <iostream>#include <cstring>#include <algorithm>using namespace std;char word[10000][20],sorted[100000][20];int cmp_string(const void*_a,const void *_b){ char *a=(char *)_a; char *b=(char *)_b; return strcmp(a,b);}int cmp_char (const void *a,const void *b){ return *(char *)a-*(char*)b;}int main(int argc, const char * argv[]) { //freopen("/Users/zhangjiatao/Desktop/input.txt","r",stdin); int n; n=0; while(1) { scanf("%s",word[n]); if(word[n][0]=='*') break; n++; } qsort(word,n,sizeof(word[0]),cmp_string); for(int i=0;i<n;i++) { strcpy(sorted[i],word[i]); qsort(sorted[i],strlen(sorted[i]),sizeof(char),cmp_char); } char s[20]; while(scanf("%s",s)==1) { int counter=0; qsort(s,strlen(s),sizeof(char),cmp_char); for(int i=0;i<n;i++) { if(strcmp(s,sorted[i])==0) { cout<<word[i]<<" "; counter++; } } if(counter!=0) cout<<endl; if(counter==0) cout<<":("<<endl; } return 0;}
0 0
- 白书练习 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- 字母重排
- //字母重排
- java-nio
- 判斷質素(一)
- 【看书】while(m)m&=m-1,s++;的解释
- CSDN博客如何改名字
- Swift: 用Alamofire做http请求,用ObjectMapper解析JSON
- 白书练习 字母重排
- 篩選質數
- 解决安装完IIS后导致路由器IP 192.168.0.1无法登陆的问题
- 爬虫小技巧(理论篇)
- rdbuf,重定向
- 元拆分成角
- Android使用videoview播放res/raw下的视频
- svn代码回滚
- 『Python』序列学习总结之一 ——列表