c语言 掷100賽子,c语言100编程实例

第一章

#include

#include

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]);

}

}

int main()

{

//fun_1();//绘制余弦直线

//fun_2();//歌星大奖赛

//fun_3();//求最大约数

//fun_4();//高次方数的尾数

//fun_5();//阶层尾数0个数

//fun_6();//三个小朋友分五本书

//fun_7();//杨辉三角

//fun_8();//二进制转换

return 0;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值