zrq495
www.zrq495.com
摘要: 题意:给出一些单词,以#结束,判断这些单词是否是ananagram。如果是按字典序输出。思路:每个大写字母变成小写,把单词中的字母按字典序排,再把单词按字典序排序,然后判断。最后输出没有改变的单词。 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 5 typedef struct 6 { 7 char s1[90]; //存放最初的单词。 8 char s2[90]; //存放小写排序后的单词。 9 int flag; //标记是否ananagram。10 }word... 阅读全文
posted @ 2012-07-17 16:32 zrq495 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 题意:求每一颗树距其他树最近的距离,如果小于10,那么相对应的距离点+1,输出距离为0,1,2,3,4,5,6,7,8,9的点的个数。用两个for循环遍历。代码如下: 1 #include<stdio.h> 2 #include<math.h> 3 4 typedef struct 5 { 6 int l, w, h; 7 }node; 8 9 int dis(node a, node b)10 {11 return (int)(sqrt( (double)((a.l-b.l)*(a.l-b.l)+(a.h-b.h)*(a.h-b.h) + (a.w-b.w)*(a.w 阅读全文
posted @ 2012-07-17 10:21 zrq495 阅读(295) 评论(0) 推荐(0) 编辑