#include<stdio.h>intmain(){int i;for(i =1; i <100;++i){if(i %3==0&& i %7!=0){printf("%d ", i);}}return0;}
2021.2
#include<stdio.h>intmain(){int i,n;longlong t,sum;scanf("%d",&n);//int上限为12 longlong上限为20for(i = t =1, sum =0; i <= n;++i){
t *= i;
sum += t;printf("%d: t:%lld m:%lld\n", i, t, sum);}printf("%lld", sum);return0;}
2021.3
#include<stdio.h>intfactsum(int n){int i, sum;for(i =1, sum =0; i < n;++i){
sum +=(n % i ?0: i);}return sum;}intmain(){int m,n,i;printf("输入m n(m<n):");scanf("%d %d",&m,&n);while(m <0|| n >1000|| m > n){puts("输入不合理,请重新输入\n");printf("输入m n(m<n):");scanf("%d %d",&m,&n);}for(i = m; i <= n;++i){if(factsum(i)== i){printf("%d ", i);}}return0;}
2021.4
#include<stdio.hintinvert(int*x,int n){int i,t;for(i =0; i < n/2;++i){
t = x[i];
x[i]= x[n - i -1];
x[n - i -1]= t;}return1;}intmain(){int a[5]={1,2,3,4,5};int n =5, i;invert(a, n);for(i =0; i < n;++i){printf("%d ", a[i]);}return0;}
2022.1
#include<stdio.h>intmain(){int n,i,sum;scanf("%d",&n);for(i =1, sum =0; i <= n;++i){
sum += i;}printf("%d", sum);return0;}
2022.2
#include<stdio.h>intmain(){int i, j;for(i =1; i <10;++i){for(j = i; j <9;++j){printf("\t");//8个空格}for(j =1; j <= i;++j){printf("%d*%d=%-3d ", j, i, i * j);//每个占8格}printf("\n");}return0;}
2022.3
#include<stdio.h>intfun(int i,int j){if(j ==1|| i == j){return1;}else{returnfun(i -1, j -1)+fun(i -1, j);}}intmain(){int i, j, n;scanf("%d",&n);for(i =1; i <= n;++i){for(j =1; j <= n - i;++j){printf(" ");}for(j =1; j <= i;++j){printf("%4d",fun(i, j));}printf("\n");}}
2022.4
#include<stdio.h>intgcd(int m,int n){int t;if(n > m){
t = n, n = m, m = t;}while(n !=0){
t = m % n;
m = n;
n = t;}return m;}intmain(){int m,n;scanf("%d %d",&m,&n);printf("最大公约数:%d\n",gcd(m, n));printf("最小公倍数:%d\n", m * n /gcd(m, n));return0;}
2022.5
#include<stdio.h>#include<math.h>intis_prime(int n){int i;if(n ==1){return0;}for(i =2; i <=sqrt(n);++i){if(n % i ==0){return0;}}return1;}intmain(){int n,i;scanf("%d",&n);for(i =1; i < n;++i){if(n % i ==0&&is_prime(i)){printf("%d ", i);}}return0;}
2022.6
#include<stdio.h>voidswap(int*a,int*b){int t;
t =*a,*a =*b,*b = t;}voidselect_sort(int*a,int n){int i, j, t,max,min;for(i =0; i < n /2;++i){
min = i;
max = i;for(j = i +1; j < n - i -2;++j){if(a[j]> a[max]){
max = j;}if(a[j]< min){
min = j;}}//todo 如果最大值在i或者if(max == i){
max = min;}swap(&a[i],&a[min]);swap(&a[n-i-1],&a[max]);}}intmain(){int a[10]={9,8,7,6,5,4,3,2,1,0};select_sort(a,10);for(int i =0; i <10;++i){printf("%d ", a[i]);}return0;}
2023.1
#include<stdio.h>intmain(){int i,j,sum;for(i =1; i <1000;++i){
sum =0;for(j =1; j < i;++j){if(i % j ==0){
sum += j;}}if(sum == i){printf("%d ", i);}}return0;}
2023.2
#include<stdio.h>intgcd(int m,int n){if(n ==0){return m;}returngcd(n, m % n);}intmain(){int m, n;scanf("%d %d",&m,&n);printf("%d\n",gcd(m, n));return0;}
2023.3
#include<stdio.h>intmain(){int i,n,t,sign;double sum;scanf("%d",&n);printf("1");for(i = sign =1, sum =0; i <= n;++i){
t = t *10+1;
sum +=1.0/(sign * t * i);if(sign <0&& i !=1){printf("-1/%d", t*i);}elseif(i !=1){printf("+1/%d", t * i);}
sign =-sign;}printf("\n%lf", sum);return0;}
2023.4
#include<stdio.h>#defineN50intpt(float*a){int i;for(i =0; i < N;++i){scanf("%f",&a[i]);if(a[i]==0){break;}}return i;}floatave(float*a,int n){float sum;int i;for(i =0; i < n;++i){
sum += a[i];}return(sum / n);}voidsort(float*a,int n){int i,j,t;for(i =0; i < n -1;++i){for(j =0; j < n - i -1;++j){if(a[j]< a[j +1]){
t = a[j];
a[j]= a[j +1];
a[j +1]= t;}}}}intmain(){float a[N],avg;int n;
n =pt(a);
avg =ave(a, n);sort(a, n);printf("n:%d\n", n);printf("avg:%f\n", avg);for(int i =0; i < n;++i){printf("%.2f ", a[i]);}return0;}