#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;
}