#include<stdio.h>intmain(){
int a[4]={
1,2,3,4}, i =0, j =0;for(int x =0; x <4; x++){
for(int y =0; y <4; y++){
for(int z =0; z <4; z++){
if((a[x]!= a[y])&&(a[x]!= a[z])&&(a[y]!= a[z])){
i = a[x]*100+ a[y]*10+ a[z];printf("%d\n", i);
j++;}}}}printf("总共有:%d个", j);return0;}
#include<stdio.h>intmain(){
int x =0, y =0;for(int i =0; i <10000; i++){
for(int m =0; m <10000; m++){
for(int j =0; j <10000; j++){
x = j +100;
y = j +268;if((x == i * i)&&(y == m * m))printf("%d\n", j);}}}return0;}
4.输入某年某月某日,判断这一天是这一年的第几天?
//输入某年某月某日,判断这一天是这一年的第几天?//先判断是不是闰年,再判断输入的月份是否大于二月;//公历闰年的简单计算方法(符合以下条件之一的年份即为闰年)//1.能被4整除而不能被100整除//2.能被400整除#include<stdio.h>intjugement(int year)//判断输入的年份是不是闰年{
int i =0;if(((0== year %4)&&(0!= year %100))||(0== year %400)){
i =1;//i置1作为标记}else
i =0;return i;}intmain(){
int j =0;int x =0;printf("请输入年月日\n");int year =0, month =0, day =0;//定义为全局变量,以便在不同函数中使用scanf("%d\n%d\n%d",&year,&month,&day);
j =jugement(year);if(1== j){
switch(month){
case1:
x = day;break;case2:
x = day +31;break;case3:
x = day +31+29;break;case4:
x = day +31+29+31;break;case5:
x = day +30+31+29+31;break;case6:
x = day +31+30+31+29+31;break;case7:
x = day +30+31+30+31+29+31;break;case8:
x = day +31+30+31+30+31+29+31;break;case9:
x = day +31+31+30+31+30+31+29+31;break;case10:
x = day +30+31+31+30+31+30+31+29+31;break;case11:
x = day +31+30+31+31+30+31+30+31+29+31;break;case12:
x = day +30+31+30+31+31+30+31+30+31+29+31;break;default:break;}}else{
switch(month){
case1:
x = day;break;case2:
x = day +31;break;case3:
x = day +31+28;break;case4:
x = day +31+28+31;break;case5:
x = day +30+31+28+31;break;case6:
x = day +31+30+31+28+31;break;case7:
x = day +30+31+30+31+28+31;break;case8:
x = day +31+30+31+30+31+28+31;break;case9:
x = day +31+31+30+31+30+31+28+31;break;case10:
x = day +30+31+31+30+31+30+31+28+31;break;case11:
x = day +31+30+31+31+30+31+30+31+28+31;break;case12:
x = day +30+31+30+31+31+30+31+30+31+28+31;break;default:break;}}printf("这一天是今年的第%d天", x);return0;}
5.输入三个整数x,y,z,请把这三个数由小到大输出
//输入三个整数x,y,z,请把这三个数由小到大输出#include<stdio.h>intmaxnumber(int x,int y,int z){
int i =0;if((x > y)&&(x > z))
i = x;elseif(((y > z)&&(y > x)))
i = y;elseif(((z > y)&&(x < z)))
i = z;return i;}intminnumber(int x,int y,int z){
int i =0;if((x < y)&&(x < z))
i = x;elseif(((y < z)&&(y < x)))
i = y;elseif(((z < y)&&(z < x)))
i = z;return i;}intmiduemnumber(int x,int y,int z){
int i =0;if((y < x)&&(x < z))
i = x;elseif(((y < z)&&(y > x)))
i = y;elseif(((z < y)&&(z > x)))
i = z;return i;}intmain(){
int x =0, y =0, z =0;int min =0, miduem =0, max =0;printf("请输入三个整数:\n");scanf("%d\n%d\n%d",&x,&y,&z);
max =maxnumber(x, y, z);
miduem =miduemnumber(x, y, z);
min =minnumber(x, y, z);printf("这三个整数从小到大分别是:\n");printf("%d\n%d\n%d", min, miduem, max);return0;}
#include<stdio.h>intmain(){
char a =176, b =219;printf("%c%c%c%c%c\n", b, a, a, a, b);printf("%c%c%c%c%c\n", a, b, a, b, a);printf("%c%c%c%c%c\n", a, a, b, a, a);printf("%c%c%c%c%c\n", a, b, a, b, a);printf("%c%c%c%c%c\n", b, a, a, a, b);return0;}
8.输出9*9口诀
#include<stdio.h>voidmain(){
int i, j, x =0;for(i =1; i <10; i++){
for(j =1; j <= i; j++){
x = i * j;printf("%d*%d=%2d ", i, j, x);if(i == j)printf("\n");//换行}}}
9.如图,要求输出国际象棋棋盘
#include<stdio.h>intmain(){
int i, j;for(i =0; i <8; i++){
for(j =0; j <8; j++){
if((i + j)%2==0)printf("%c%c",'\xA1','\xF6');//打印出白格子elseprintf(" ");}printf("\n");}return0;}
10.打印楼梯,同时在楼梯上方打印两个笑脸
#include<stdio.h>intmain(){
int i, j;/*
作用是打印出ASCII码为1的字符。查询ASCII码表中,十进制的1对应的ASCII意思是soh,
即start of head,标题开头的意思。该符号为通信专用字符,如果只是用作显示,
系统会使用一个特定的图形来显示,这就是我们看到的笑脸
*/printf("\1\1\n");for(i =1; i <11; i++){
for(j =1; j <= i; j++){
printf("%c%c",77,77);}printf("\n");}return0;}
#include<stdio.h>inttiqu(int n){
int x =0, y =0, z =0;//分别存放百位、十位、个位int i =0;
z = n %10;//得到个位数
x = n /100;//得到百位数
y =(n - z - x *100)/10;//得到十位数
i = x * x * x + y * y * y + z * z * z;return i;}voidmain(){
int j, sum =0;//j用来计数,sum用来接收tiqu()的返回值for(j =100; j <1000; j++){
sum =tiqu(j);if(sum == j)printf("%d ", j);}}
14.将一个正整数分解质因数。例如:输入90,打印出90=233*5
#include<stdio.h>voidmain(){
int a, n;scanf("%d",&n);printf("%d=", n);for(a =2; a <= n; a++){
if(n % a ==0){
n = n / a;printf("%d*", a);
a =1;}}}
#include<stdio.h>intgongbeishu(int m,int n){
int i, j =0;for(i =2; i <= n, i <= m; i++)//for循环求得最大公倍数{
if((0== m % i)&&(0== n % i))
j = i;}
j =(m * n)/ j;//两个数的乘积除以最大公倍数便得到最小公约数return j;}intgongyueshu(int m,int n){
int i, j =0;for(i =2; i <= n, i <= m; i++){
if((0== m % i)&&(0== n % i))
j = i;}return j;}intmain(){
int m, n;printf("请输入两个数\n")