code for fun

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

2013年5月10日

摘要: 描述Palindromes are strings that read the same both forwards and backwards. `Eye' is one such example (ignoring case). In this problem, you get to write a program to determine if a given word is a palindrome or not. 输入Each line of input contains one word with no embedded spaces. Each word will hav 阅读全文
posted @ 2013-05-10 13:45 xueda120 阅读(273) 评论(0) 推荐(0) 编辑

摘要: 描述求n个数的最小公倍数。 输入输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数。输出为每组测试数据输出它们的最小公倍数,每个测试实例的输出占一行。你可以假设最后的输出是一个32位的整数。样例输入2 4 63 2 5 7样例输出1270 1 #include<stdio.h> 2 #include<math.h> 3 #include<string.h> 4 #include<ctype.h> 5 6 int a[1000]; 7 8 int gcd(int x,int y) //计算两个数的最大公约数 9 {10 whi 阅读全文
posted @ 2013-05-10 10:43 xueda120 阅读(260) 评论(0) 推荐(0) 编辑

摘要: 描述已知va和vb分别为非递减有序线性表,将va和vb进行合并为新的线性表vc,并保持vc仍然非递减有序。本题中,线性表元素为整数。线性表的最大长度为1000。输入输入数据有多组,第一行为测试数据的组数n,接下来为2n行,每一组测试数据有两行:第一行的第一个数为va的元素个数,后面是n个整数,代表va的所有元素第二行的第一个数为vb的元素个数,后面是n个整数,代表vb的所有元素输出输出合并后的长度以及vc的所有元素样例输入22 1 22 2 33 1 2 33 4 5 6样例输出4 1 2 2 36 1 2 3 4 5 6提示你也可以使用链表来实现,有空也练练吧 1 #include<s 阅读全文
posted @ 2013-05-10 00:24 xueda120 阅读(669) 评论(0) 推荐(0) 编辑