read1

#include <stdio.h>

 

int main()

{

 

const int MINOR = 35;

 

int age = 0;

 

printf("请输入你的年龄: ");

scanf("%d", &age);

 

printf("你的年龄是%d岁。\n", age);

 

if ( age < MINOR ) {

    printf("年轻是美好的,");

}

 

printf("年龄决定了你的精神世界,好好珍惜吧。\n");

 

return 0;

}

----

// max3.c

#include <stdio.h>

 

int main()

{

int a,b,c;

scanf("%d %d %d", &a, &b, &c);

 

int max = 0;

 

if ( a>b ) {

if ( a>c ) {

max = a;

} else {

max = c;

}

} else {

if ( b>c ) {

max = b;

} else {

max = c;

}

}

 

printf("The max is %d\n", max);

 

return 0;

}

-----------

#include <stdio.h>

 

int main()

{

const double RATE = 8.25;  

const int STANDARD = 40;   

double pay = 0.0;

int hours;

 

printf("请输入工作的小时数: ");

scanf("%d", &hours);

printf("\n");

if (hours > STANDARD)

    pay = STANDARD * RATE + 

    (hours-STANDARD) * (RATE * 1.5);

else

    pay = hours * RATE;

printf("应付工资: %f\n", pay);

 

return 0;

}

---

#include <stdio.h>

 

int main()

{

int n = 3;

 

while ( n>= 0 ) {

printf("%d ", n);

n--;

}

printf("发射\n");

 

return 0;

}

----

#include <stdio.h>

 

int main()

{

int number = rand()%100+1;

int count = 0;

int a = 0;

printf("我已经想好了一个1到100之间的数。");

do {

printf("请猜这个1到100之间数:");

scanf("%d", &a);

if ( a > number ) {

printf("你猜的数大了。");

} else if ( a < number ) {

printf("你猜的数小了。");

}

count ++;

} while (a != number);

printf("太好了,你用了%d次就猜到了答案。\n", count);

 

return 0;

}

---

// log2x

 

#include <stdio.h>

 

int main()

{

int x;

int ret = 0;

 

scanf("%d", &x);

int t = x;

while ( x > 1 ) {

x /= 2;

ret ++;

}

printf("log2 of %d is %d.", t, ret);

 

return 0;

}

---

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

 

int main()

{

srand(time(0));

int a = rand();

printf("%d\n", a%100);

 

return 0;

}

---

#include <stdio.h>

 

int main()

{

int x;

scanf("%d", &x);

int digit;

int ret = 0;

 

while ( x> 0 ) {

digit = x%10;

printf("%d", digit);

ret = ret*10 + digit;

// printf("x=%d,digit=%d,ret=%d\n", x, digit, ret);

x /= 10;

}

// printf("%d", ret);

return 0;

}

---

#include <stdio.h>

 

int main()

{

int x;

int one, two, five;

scanf("%d", &x);

for ( one = 1; one < x*10; one++ ) {

for ( two = 1; two < x*10/2; two++ ) {

for ( five = 1; five < x*10/5; five++ ) {

if ( one + two*2 + five*5 == x*10 ) {

printf("可以用%d个1角加%d个2角加%d个5角得到%d元\n", 

one, two, five, x);

break;

}

}

}

}

return 0;

}

#include <stdio.h>

int main()
{
	int x;
	int one, two, five;
	
	scanf("%d", &x);
	for ( one = 1; one < x*10; one++ ) {
		for ( two = 1; two < x*10/2; two++ ) {
			for ( five = 1; five < x*10/5; five++ ) {
				if ( one + two*2 + five*5 == x*10 ) {
					printf("可以用%d个1角加%d个2角加%d个5角得到%d元\n", 
						one, two, five, x);
					break;
				}
			}
		}
	}
	
	return 0;
}
#include <stdio.h>

int main()
{
	int x;
	int one, two, five;
	int exit = 0;
	
	scanf("%d", &x);
	for ( one = 1; one < x*10; one++ ) {
		for ( two = 1; two < x*10/2; two++ ) {
			for ( five = 1; five < x*10/5; five++ ) {
				if ( one + two*2 + five*5 == x*10 ) {
					printf("可以用%d个1角加%d个2角加%d个5角得到%d元\n", 
						one, two, five, x);
					exit = 1;
					break;
				}
			}
			if ( exit == 1 ) break;
		}
		if ( exit == 1 ) break;
	}
	
	return 0;
}

--

#include <stdio.h>

int main()
{
	int x;
	int one, two, five;
	
	scanf("%d", &x);
	for ( one = 1; one < x*10; one++ ) {
		for ( two = 1; two < x*10/2; two++ ) {
			for ( five = 1; five < x*10/5; five++ ) {
				if ( one + two*2 + five*5 == x*10 ) {
					printf("可以用%d个1角加%d个2角加%d个5角得到%d元\n", 
						one, two, five, x);
					goto out;
				}
			}
		}
	}
out:	
	return 0;
}
#include <stdio.h>

int main()
{
	int x;

	scanf("%d", &x);
	
	int i;
	int isPrime = 1;	//	x是素数
	for ( i=2; i<x; i++ ) {
		if ( x % i == 0 ) {
			isPrime = 0;
			break;
		}
	}
	if ( isPrime == 1 ) {
		printf("是素数\n");
	} else {
		printf("不是素数\n");
	}
	return 0;
}
#include <stdio.h>

int main()
{
	int x;
	
	for ( x=1; x<=100; x++ ) {
		int i;
		int isPrime = 1;	//	x是素数
		for ( i=2; i<x; i++ ) {
			if ( x % i == 0 ) {
				isPrime = 0;
				break;
			}
		}
		if ( isPrime == 1 ) {
			printf("%d ", x);
		} 
	}
	printf("\n");
	return 0;
}
#include <stdio.h>

int main()
{
	int x;
	int cnt = 0;

	x = 1;
	while ( cnt <50 ) {
		int i;
		int isPrime = 1;	//	x是素数
		for ( i=2; i<x; i++ ) {
			if ( x % i == 0 ) {
				isPrime = 0;
				break;
			}
		}
		if ( isPrime == 1 ) {
			cnt ++;
			printf("%d\t", x);
			if ( cnt %5 == 0 ) {
				printf("\n");
			}
		} 
		x++;
	}
	return 0;
}

 

转载于:https://my.oschina.net/u/3127489/blog/1551028

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值