#include<stdio.h>#include<math.h>intmain(int argc,char*argv[]){for(int i =4; i <=100;++i){int t =0;for(int j =2; j <=sqrt(i);++j){if(!(i % j)){if(j != i / j){
t += j +(i / j);}else{
t += j;}}}if(t +1== i){printf("%d ", i);}}}
百钱百鸡
#include<stdio.h>intmain(int argc,char*argv[]){for(int i =0; i <20;++i){for(int j =0; j <33;++j){for(int k =0; k <100;++k){if(5* i +3* j + k ==100&& i + j +3* k ==100){printf("公鸡:%d,母鸡:%d,小鸡:%d\n", i, j,3* k);}}}}}
斐波那契数列
#include<stdio.h>intmain(int argc,char*argv[]){int a =1, b =1;printf("%d ", a);printf("%d ", b);for(int i =2; i <10;++i){
b = a + b;
a = b - a;printf("%d ", b);}}
上衣59,裤子70,一套120,买了m个上衣和n条裤子,多少钱?
#include<stdio.h>intmain(int argc,char*argv[]){int m, n;printf("上衣:");scanf("%d",&m);printf("裤子:");scanf("%d",&n);if(m > n){printf("一共%d元", n *120+(m - n)*59);}else{printf("一共%d元", m *120+(n - m)*70);}}