- #include "stdio.h"
{
int a;
scanf("%d",&a);
printf("%x,%o,%d",a,a,a);
}
2、#include "stdio.h"
void main()
{
float a;
scanf("%d",a);
printf("%8.4f\n",a);
printf("%09.3f\n",a);
}
3、#include "stdio.h"
void main()
{
int x;
scanf("%d",x);
if(x>-1&&x<10)
printf("ok");
else
printf("not ok");
}
4、#include "stdio.h"
void main()
{
int a;
scanf("%d",&a);
if(a>=100)
{
if(a>1000)
printf("big");
else
printf("middle");
}
else
printf("small");
}
5、#include "stdio.h"
void main()
{
int a;
printf("请输入一个数字1和12之间:");
scanf("%d",&a);
switch(a)
{
case 1:printf("yiyue");break;
case 2:printf("eryue");break;
case 3:printf("sanyue");break;
case 4:printf("si");break;
case 5:printf("wu");break;
case 6:printf("liu");break;
case 7:printf("qi");break;
case 8:printf("ba");break;
case 9:printf("jiu");break;
case 10:printf("shi");break;
case 11:printf("shiyi");break;
case 12:printf("shier");break;
default:printf("not valid month number\n");
}
}
6、#include "stdio.h"
void main()
{
int a,sum;
sum=0;
for(a=2;a<=100;a=a+2)
sum=a+sum;
printf("%d",sum);
}
7、#include "stdio.h"
void main()
{
int a,sum;
sum=0;
a=2;
while(a<=100)
{
sum=sum=a;
a=a+2;
}
printf("%d",sum);
}
8、#include "stdio.h"
void main()
{
int a,sum;
sum=0;
a=2;
do
{
sum=sum+a;
a=a+2;
}
while(a<=100);
printf("%d",sum);
}