2016年3月5日
摘要: 1 //程序4-5 2 #include <stdio.h> 3 void swap(int* a, int* b) 4 { 5 int t = *a; *a = *b; *b = t; //*a是指“a指向的变量”,而不仅是“a指向的变量所拥有的值” 6 } 7 8 int main() 9 { 阅读全文
posted @ 2016-03-05 22:21 tostring_char 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 1 //例题4-2 2 /* 3 *如果n和n+2都是素数,则称它们是孪生素数。输入m,输出两个数均不超过m的最大孪生素数。5<=m<=100。例如m=2时答案是17、19,m=1000时答案是881、883。 4 */ 5 6 //程序4-2 孪生素数(1) 7 #include <stdio.h 阅读全文
posted @ 2016-03-05 22:01 tostring_char 阅读(971) 评论(0) 推荐(0) 编辑
摘要: 1 //例题4-1 2 /* 3 *输入非负整数m和n,输出组合数,其中m≤n≤20。 4 */ 5 #include <stdio.h> 6 7 int f(int n) //因多次出现n!,将其作为一个函数来编写 8 { 9 int i, m = 1; 10 for(i = 1; i <= n; 阅读全文
posted @ 2016-03-05 20:15 tostring_char 阅读(187) 评论(0) 推荐(0) 编辑
2016年3月4日
摘要: 1 //例题3-4 2 /* 3 * 输入一个字符串,求出其中最长的回文子串。子串的含义是:在原串中连续出现的字符串片段。 4 *回文的含义是:正看着和倒看着相同,如abba和yyxyy。在判断时,应该忽略所有标点符号和空格 5 *且忽略大小写,但输出应保持原样(在回文串的首部和尾部不要输出多余字符 阅读全文
posted @ 2016-03-04 22:03 tostring_char 阅读(408) 评论(0) 推荐(0) 编辑