随笔分类 -  算法训练

摘要://整数平均值 #include<stdio.h> int main(){ int n; int sum; scanf("%d\n",&n); int a[n]; for(int i=0;i<n;i++){ scanf("%d",&a[i]); sum += a[i]; } printf("%d", 阅读全文
posted @ 2020-01-28 21:57 Hqx_curiosity 阅读(211) 评论(0) 推荐(0)
摘要://字符删除 #include<stdio.h> #include<String.h> int main(){ char str[20],str2[20]; char ch; int length,i,j = 0; scanf("%s\n",&str); scanf("%c",&ch); lengt 阅读全文
posted @ 2020-01-28 17:18 Hqx_curiosity 阅读(237) 评论(0) 推荐(0)
摘要://最大的算式 //对输入的N个数逆序排序,前K个数的积乘于剩余N-K个数的和 #include<stdio.h> #include<stdlib.h> #define MAXN 100 int comp(const void*a,const void*b)//用来做比较的函数。 { return 阅读全文
posted @ 2020-01-28 15:28 Hqx_curiosity 阅读(236) 评论(0) 推荐(0)
摘要://最大值与最小值 #include<stdio.h> #include<stdlib.h> #define MAXN 100 int comp(const void*a,const void*b)//用来做比较的函数。 { return *(int*)a - *(int*)b; } int mai 阅读全文
posted @ 2020-01-28 10:00 Hqx_curiosity 阅读(199) 评论(0) 推荐(0)
摘要://最大最小公倍数 // #include<stdio.h> int main(){ int n; scanf("%d",&n); //连续3个数 奇偶奇 互质 if(n<=2) printf("2"); else if(n==3) printf("6"); else if(n%2==1) prin 阅读全文
posted @ 2020-01-28 09:54 Hqx_curiosity 阅读(177) 评论(0) 推荐(0)
摘要://最小乘积(基本型) #include<stdio.h> #include<stdlib.h> #define MAXN 100 int comp_a2(const void*a,const void*b)//用来做比较的函数。 { return *(int*)a - *(int*)b; } in 阅读全文
posted @ 2020-01-28 07:36 Hqx_curiosity 阅读(203) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<string.h> int main(){ int a[5],i,max; char str[5][100]; for(i=0;i<5;i++){ scanf("%s",str[i]); a[i] = strlen(str[i]); } for( 阅读全文
posted @ 2020-01-27 19:47 Hqx_curiosity 阅读(197) 评论(0) 推荐(0)