摘要: 把一串密码译成正文,密码以字符@结束,译码规则如下 ①如果是字母,则转换成下一个字母 ②如果是字母Z译成A ③无论大小写字母都译成小写字母 ④其他字符一律按原样译出 1 //第一种if写法 2 #include<stdio.h> 3 int main() 4 { 5 char ch; 6 while 阅读全文
posted @ 2020-03-17 21:22 新生代农民工 阅读(509) 评论(0) 推荐(0)
摘要: 1 #include<stdio.h> 2 int main() 3 { 4 char ch; 5 while ((ch=getchar())!='\n') 6 { 7 if (ch>='a'&&ch<='z') 8 { 9 ch = ch - 'a' + 'A'; //只需减去字母表首字母得到多少 阅读全文
posted @ 2020-03-17 20:52 新生代农民工 阅读(752) 评论(0) 推荐(0)
摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int x, y, a[10][10] = { 0 }; 5 for (x = 0; x < 10;x++) //把首列和对角线赋值为1,以便后面计算 6 { 7 a[x][x] = 1; 8 a[x][0] = 1; 9 阅读全文
posted @ 2020-03-16 21:41 新生代农民工 阅读(94) 评论(0) 推荐(0)
摘要: 1 /* 2 这种头尾交换数值只需要循环一半 3 头尾分别交换值即可 4 */ 5 #include<stdio.h> 6 int main() 7 { 8 int a[5] = { 8, 6, 5, 4, 1 }; 9 int i,j, temp; 10 temp = 0; 11 for (i = 阅读全文
posted @ 2020-03-16 16:29 新生代农民工 阅读(172) 评论(0) 推荐(0)
摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int a[11] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; 5 int temp, c, b,temp2; 6 for (c = 0; c < 10; c++) 7 { 8 printf(" 阅读全文
posted @ 2020-03-16 15:36 新生代农民工 阅读(125) 评论(0) 推荐(0)
摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int a, b, temp, c[10] = { 2, 5, 1, 7, 4, 8, 9, 3, 6, 0 }; 5 for (a = 0; a <= 8;a++) //从首位遍历数组最后一位数不需要遍历 6 { 7 f 阅读全文
posted @ 2020-03-16 14:35 新生代农民工 阅读(132) 评论(0) 推荐(0)
摘要: 1.解释下什么是筛选法? 筛选法又称筛法,具体做法是:先把N个自然数按次序排列起来。1不是质数,也不是合数,要划去。第二个数2是质数留下来,而把2后面所有能被2整除的数都划去。2后面第一个没划去的数是3,把3留下,再把3后面所有能被3整除的数都划去。3后面第一个没划去的数是5,把5留下,再把5后面所 阅读全文
posted @ 2020-03-16 14:09 新生代农民工 阅读(1202) 评论(0) 推荐(0)
摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int a[3][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };//随意定义数组 5 int sum1, sum2, k, j; //定义输出的变量和循环的变量 6 sum1 = 0; 7 sum2 阅读全文
posted @ 2020-03-15 19:07 新生代农民工 阅读(727) 评论(0) 推荐(0)
摘要: 两个乒乓球队进行比赛,各出3人。甲队为A,B,C 3人,乙队为X,Y,Z 3人。已抽签决定比赛名单。 有人向队员打听比赛的名单,A说他不和X比,C说他不和X,Z比,请编程序找出3对赛手的名单。 1 #include<stdio.h> 2 int main() 3 { 4 char i, j, k; 阅读全文
posted @ 2020-03-15 16:47 新生代农民工 阅读(644) 评论(0) 推荐(0)
摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int i; 5 double a, b, c, e; 6 a = 2; 7 b = 1; 8 c = 0; 9 e = 0; 10 for (i = 1; i <= 20; i++) 11 { 12 e = e + a 阅读全文
posted @ 2020-03-15 15:52 新生代农民工 阅读(181) 评论(0) 推荐(0)