c无聊编程
#include<stdio.h> #include<math.h> void fun_1()//绘制余弦直线 { double y; int m, x; for (y = 1; y >= -1; y -= 0.1) { m = acos(y)*10; for (x = 1; x < m; x++)printf(" "); printf("*"); for (; x < 62 - m; x++)printf(" "); printf("*\n"); } int x_1, y_1; x_1 = 0; for (y_1 = 0; y_1 <= 10; y_1++) for(x_1=0;x_1<=y_1;x_1++){ if(x_1==y_1) { printf("*\n"); } else { printf(" "); } } } void fun_2() { int i, max, min, sum=0, num[4] = {20,90,85,84}; max = min = num[0]; printf("max%d\n", max); printf("min%d\n", min); printf("score:\n"); for (i = 0; i < 4; i++) printf("%d\n", num[i]); for (i = 0; i < 4; i++) { sum += num[i]; if (max < num[i]) { max = num[i]; } if (min > num[i])min = num[i]; } sum = sum - max - min; printf("avg%dmin%dmax%d", sum / 2,min,max); } void fun_3() { int i; long j;//N的数值 j = 555555; for (i = 999; i > 100; i--) { if (j%i == 0) { printf("factor:%d", i); break; } } } void fun_4() { int x, y,last=1; x = 13; for (y = 13; y > 0; y--) { last = last*x%1000; } printf("%d",last); } void fun_5() { int a, count = 0; for (a = 5; a <= 100; a = a + 5) { count++; if (!(a % 25))count++; } printf("%d",count); } void fun_6() { int a, b, c, count=0; for (a = 1; a <= 5; a++) for (b = 1; b <= 5; b++) for (c = 1; c <= 5 && a != b; c++) if (c != a&&c != b)count++; printf("%d",count); } void fun_7() { int n = 13,i,j; for (i = 0; i < n; i++) { for (j = 0; j < 12-i; j++)printf(" "); for (j = 1; j < i + 2; j++)printf("%6d", fun_7_f(i, j)); printf("\n"); } } int fun_7_f(int x,int y)//fun_7子函数进行递归 { int z; if (y == 1 || y ==x + 1)return 1; z = (x - 1, y - 1) + (x - 1, y); return z; } void fun_8() { int data[16]; int i = 0; int x=98; printf("%d\n", x); for (i = 0;i<8; i++) { data[i] = x % 2; x = x / 2;// printf("%d\n", x); //printf("%d\n", data[i]); } for (i = 8; i > 0; i--) { if (data[i] == 1) for (; i >= 0; i--)printf("%d", data[i]); } } struct data { int year; int mouth; int day; }; void fun_2_1() { struct data trem; trem.year = 1991; trem.mouth = 10; trem.day = 25; int day_tab[2][12]={ {31,28,31,30,31,30,31,31,30,31,30,31},{ 31,29,31,30,31,30,31,31,30,31,30,31 } }; int i, yearf, mouthf, dayf; yearf = mouthf = dayf = 0; for (i = trem.year; i > 1991; i--) { if (i % 4 == 0 && i % 100 != 0) dayf =dayf+366; else dayf = dayf + 365; printf("year+%d\n", dayf); } for (i = 0; i <trem.mouth-1; i++) { if (trem.year % 4 == 0 && trem.year% 100 != 0) dayf = dayf + day_tab[1][i]; else dayf = dayf + day_tab[0][i]; printf("mouthday+%d\n", dayf); } dayf = dayf + trem.day; printf("mouthday+%d\n", dayf); int f; f = dayf % 5; printf("%d", f); switch (f) { case 1:; case 2:; case 3:printf("flash"); break; default:printf("sleep"); } } void fun_2_2() { int i, j, k, l; for (i = 1; i < 10; i++) { for (j = 1; j < 10; j++) { if (i != j) { k = i * 1000 + i * 100 + j * 10 + j; for (l = 31; l*l < k; l++); if (l*l == k)printf("OK\t%d", k); } } } } int main() { //fun_1();//绘制余弦直线 //fun_2();//歌星大奖赛 //fun_3();//求最大约数 //fun_4();//高次方数的尾数 //fun_5();//阶层尾数0个数 //fun_6();//三个小朋友分五本书 //fun_7();//杨辉三角 //fun_8();//二进制转换 //fun_2_1();//三天打鱼两天晒网 //fun_2_2();//根据描述追踪车牌号 fun_2_3(); return 0; }