static.关键字,指针大小 ————作业三

#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
int sum(int a)
{
	int c = 0;
	static int b = 3;
	c += 1;
	b += 2;
	return (a+b+c);
}
int main() {

	int i;
	int a = 2;
	for (i = 0; i < 5; i++)
	{
		printf("%d,", sum(a));
	}
}

 

 

int func(int a)
{
	int b;
	switch (a)
	{
	case 1:b = 30;
	case 2:b = 20;
	case 3:b = 16;
	default:b = 0;
	}
	return b;
}


int main() {
	int x = 3;
	int y = 3;
	switch (x % 2){
		case 1:
	switch (y)
	{

	case 0:
		printf("first");
	case 1:
		printf("second");
		break;
	default:printf("hello");
	}
	case 2:
		printf("third");
}

	return 0;

}

 

int main() {
	int a = 0;
	int b = 0;
	int c = 0;
	scanf_s("%d%d%d",&a,&b,&c);
	//算法实现 a中放最大值 b其次 c最小值
	if (a < b)
	{
		int tmp = a;
		a = b;
		b = tmp;
	}
	if (a < c)
	{
		int tmp = a;
		a = c;
		c = tmp;
	}
	if (b < c)
	{
		int tmp = b;
		b = c;
		c = tmp;

	}

	printf("%d %d %d\n",  a, b, c);

	return 0;
}

 

int main() {

	int i = 0;
	for (i = 1; i <= 100; i++)
	{
		if (i % 3 == 0)
			printf("%d ", i);
	}
	
	return 0;
}

 

int main() {
	int m = 24;
	int n = 18;
	int r = 0;
	while (m%n)
	{
		r = m % n;
		m = n;
		n = r;
	}
	printf("%d\n", n);
	return 0;
	}

 

int main() {
	int year = 0;
	int count = 0;
	for (year = 1000; year <= 2000; year++)
	{
		//判断year是否为闰年
		//1.能被4整除并且不能被100整除是闰年
		//2.能被400整除是闰年

	/*	if (year % 4 == 0 && year % 100 != 0)
		{
			printf("%d ", year);
			count++;
		}
		else if (year % 400 == 0)
		{
			printf("%d ", year);
			count++;
		}*/
		if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
		{
			printf("%d ", year);
			count++;
		}
	}
	printf("%d ", count);

	return 0;

 

int main() {
	int i = 0;
	int count = 0;
	for (i = 100; i <= 200; i++)
	{
		//判断:是否为素数
		//素数的判断规则
		//1.试除法
		
		int j = 0;
		for (j = 2; j < i; j++)
		{
			if (i % j == 0)
			{
				break;
			}

		}
		if (j == i) {
			count++;
			printf("%d ", i);
		}
	}
	printf("%d\n", count);
	return 0;
}

#include<math.h>
int main() {
	int i = 0;
	int count = 0;
	for (i = 100; i <= 200; i++)
	{
		//判断:是否为素数
		//素数的判断规则
		//1.试除法
		
		int j = 0;
		for (j = 2; j <=sqrt(i); j++)
		{
			if (i % j == 0)
			{
				break;
			}

		}
		if (j>sqrt(i)) {
			count++;
			printf("%d ", i);
		}
	}
	printf("%d\n", count);
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值