博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[code]字母重排
阅读量:6868 次
发布时间:2019-06-26

本文共 1099 字,大约阅读时间需要 3 分钟。

567993-20160316211058209-103008666.png
567993-20160316211058646-369731825.png
567993-20160316211058912-725288596.png
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int 
n;
char 
word[ 1000][10 ],sorted[ 1000][10 ];
//字符比较函数
int 
cmp_char(
const 
void 
* _a, 
const 
void 
*_b)
{
    
char
* a=(
char
*)_a ;
    
char
* b=(
char
*)_b ;
    
return 
*a-* b;
}
int 
cmp_string(
const 
void 
* _a,
const 
void 
* _b)
{
    
char
* a=(
char 
*) _a;
    
char
* b=(
char 
*) _b;
    
return 
strcmp 
(a, b);
}
 
void 
main()
{
    
int 
i;
    
char 
s[10 ];
    
n=0 ;
    
for
(;;)
    
{
        
scanf 
(
"%s"
,word[n ]);
         
if
(word [n][ 0]==
'*' 
)
break
;
        
n ++;
    
}
    
qsort
(word ,n, 
sizeof
(word [0]), cmp_string);
// 给所有单词排序
    
for
(i=0 ;i< n;i++)
    
{
        
strcpy 
(sorted[ i],word[i ]);
        
qsort 
(sorted[ i],
strlen
(sorted [i]), 
sizeof
(
char 
),cmp_char);
    
}
 
    
while
(
scanf
(
"%s" 
,s)== 1)
// 持续督导文件结束
    
{
         
int 
found =0;
        
qsort 
(s, 
strlen
(s ),
sizeof
(
char
),cmp_char );
         
for
(  i =0; i<n;i ++)
             
if
(
strcmp 
(sorted[ i],s)==0 )
             
{
                
found =1;
                
printf 
(
"%s "
,word[i ]);
             
}
             
if
(!found )
printf
":("
);
            
printf 
(
"\n"
);
    
}
}
来源: 

转载于:https://www.cnblogs.com/zhxshseu/p/5285179.html

你可能感兴趣的文章
Vue混入mixins
查看>>
前阿里 P9 级员工称离婚是模拟测试,已回滚复婚!
查看>>
衡阳a货翡翠,南平a货翡翠
查看>>
Loadrunner11如何使用非IE浏览器录制脚本
查看>>
ACL-文件访问控制列表
查看>>
css解决div子元素margin溢出的问题
查看>>
linux内核参数注释与优化
查看>>
grep小练习
查看>>
英语文章、常用短语部分摘选集锦
查看>>
ADMT3.2域迁移之Server2003至Server2012系列(七)安装ADMT3.2
查看>>
DISPLAY环境变量的作用
查看>>
006.递归和分治思想
查看>>
org.springframework.data.mapping.PropertyReferenceException: No property xxxx found for type Xxxx
查看>>
Gson解析json数据 亲自测试可用
查看>>
我与监控宝之间的点点滴滴
查看>>
delphi 数据库显示的TDBGrid配置
查看>>
对51CTO的看法
查看>>
userenv和sys_context函数
查看>>
是否会回到起点.回忆只能是回忆
查看>>
原创数据结构算法Flash动画演示课件-Action Script(AS)脚本实现
查看>>