1:
#include "stdio.h"
main()
{
int x,y,z,t;
scanf("%d%d%d",&x,&y,&z);
if (x>y)
{
t=x;x=y;y=t;
} /*交换x,y的值*/
if(x>z)
{
t=z;z=x;x=t;
}/*交换x,z的值*/
if(y>z)
{
t=y;y=z;z=t;
}/*交换z,y的值*/
printf("small to big: %d %d %d\n",x,y,z);
}
2:
#include
void main()
{
int i,sum=0;
for(i=1;i<=100;i+=2)
sum+=i;
printf("%d\n",sum); //奇数之和
}
#include
void main()
{
int i,sum=0;
for(i=0;i<=100;i+=2)
sum+=i;
printf("%d\n",sum); //偶数之和
}
3:
#include"stdio.h"
void main()
{
double r,s;
printf("请输入圆的半径r=");
scanf("%lf",&r);
s=3.1415926*r*r;
printf("面积=%.2lf",s);
printf("\n");
}
4:
int i = int.Parse( Console.ReadLine() );
switch(i)
{
case 1:
Console.WriteLine(" Excellent");
break;
case 2:
Console.WriteLine("Good");
break;
case 3:
Console.WriteLine("Pass");
break;
if语句
if (i == 1)
{
Console.WriteLine(" Excellent");
}
if (i == 2)
{
Console.WriteLine("Good");
}
#include"stdio.h"main(){intx,y,z,t;scanf("%d%d%d",&x,&y,&z);if(x>y){t=x;x=y;y=t;}/*交换x,y的值*/if(x>z){t=z;z=x;x=t;}/*交换x,z的值*/if(y>z){t=y;y=z;z=t;}/*交换z,y的值*/printf("smalltobig:%d%d%d\n",x,y,z);}