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) 编辑