if语句:
#include<stdio.h>
int main()
{
int a;
scanf("%d", &a);
if (a >=0 && a < 3)
{
printf("小\n");
}
else if (a >= 3 && a < 6)
{
printf("中\n");
}
else if (a >= 6 && a < 9)
{
printf("大\n");
}
else
{
printf("不考虑\n");
}
return 0;
}
switch语句:
#include<stdio.h>
int main()
{
int a=0;
scanf("%d", &a);
switch (a)
{
case 1:
case 2:
case 3:
printf("小\n");
break;
case 4:
case 5:
case 6:
printf("中\n");
break;
case 7:
case 8:
case 9:
printf("大\n");
break;
default:printf("不考虑\n");
break;
}
return 0;
}
while循环:
#include<stdio.h>
int main()
{
int a=0;
while (a < 10)
{
printf("%d\n", a);
a++;
}
return 0;
}
for循环:
#include<stdio.h>
int main()
{
int a=0;
for (a = 0; a < 10; a++)
{
printf("%d\n", a);
}
return 0;
}
do while循环:
#include<stdio.h>
int main()
{
int a=0;
do
{
printf("%d\n", a);
a++;
} while (a < 10);
return 0;
}