3-基礎級-3-(1-5)題解

基礎級-3-(1-5)題解 - (飆程式網分站)

基礎級-第三級-(1-5)題解:

================================

3-1

--------------------------------

#include <stdio.h>

int main()

{

int year;

scanf("%d",&year);

if((year%4==0)&&(year%100!=0))

{

printf("Yes");

}

else if(year%400==0)

{

printf("Yes");

}

else

{

printf("No");

}

return 0;

}

--------------------------------

3-2

--------------------------------

#include <stdio.h>

int main()

{

int x,y;

scanf("%d%d",&x,&y);

if(x>y)

printf("%d",x);

else

printf("%d",y);

return 0;

}

--------------------------------

3-3

--------------------------------

#include <stdio.h>

int main()

{

int a,b,c;

scanf("%d%d%d",&a,&b,&c);

if((a<=b && b<=c)||(c<=b && b<=a))

printf("Yes");

else

printf("No");

return 0;

}

--------------------------------

3-4-1

--------------------------------

#include <stdio.h>

int main(){

int a,b,c,d,x;

scanf("%d%d%d%d%d",&a,&b,&c,&d,&x);

if(x==1)

printf("%d",a);

if(x==2)

printf("%d",b);

if(x==3)

printf("%d",c);

if(x==4)

printf("%d",d);

return 0;

}

--------------------------------

3-4-2

--------------------------------

#include <stdio.h>

int main()

{

int a,b,c,d,x;

scanf("%d%d%d%d%d",&a,&b,&c,&d,&x);

switch (x)

{

case 1:

printf("%d",a);

break;

case 2:

printf("%d",b);

break;

case 3:

printf("%d",c);

break;

case 4:

printf("%d",d);

break;

}

return 0;

}

--------------------------------

3-5

--------------------------------

#include<stdio.h>

#include<stdlib.h>

int main()

{

int x;

scanf("%d",&x);

if(x<=1000 && x>=-1000)

{

printf("GET %d\n",x);

if(x>0)

printf("P\n");

else if(x<0)

printf("N\n");

if(x%2==0)

printf("E");

else

printf("O");

}

return 0;

}

--------------------------------