首页 > 代码库 > pat_1

pat_1

2-0

 

2-1

#include <stdio.h>int main()  {    int inch,foot,cm;    scanf("%d",&cm);    foot=cm/30.48;    inch=cm*12/30.48-foot*12;    printf("%d %d\n",foot,inch);    return 0;}
View Code

 

2-2

#include <stdio.h>int main()  {    int h,min,time;    int tmp;    scanf("%d%d",&tmp,&time);    h=tmp/100;    min=tmp%100;    min+=time%60;    if(min>=60)    {        h+=min/60;        min=min%60;    }    if(min<0)    {        h-=1;        min+=60;    }    h+=time/60;    printf("%d%02d\n",h,min);    return 0;}
View Code

 

2-3

#include <stdio.h>int main()  {    int tmp;    int a,b,c;    scanf("%d",&tmp);    c=tmp%10;    b=tmp/10%10;    a=tmp/100;    if(c!=0)    {        printf("%d%d%d",c,b,a);return 0;    }    if(b!=0)    {        printf("%d%d",b,a);return 0;    }    printf("%d\n",a);    return 0;}
View Code