hdu 2030

统计给定文本文件中汉字的个数。首先知道汉字机内码是两个负数ASCII码组成。然后就水了

 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5     int n,i,len,j,count;
 6     char a[1000];
 7     while(scanf("%d",&n)!=EOF)
 8     {
 9         getchar();
10         for (i=1;i<=n;i++)
11         {
12             count=0;
13             gets(a);
14             len=strlen(a);
15             for (j=0;j<len;j++) if (a[j]<0) count++;
16             printf("%d\n",count/2);
17         }
18     }
19     return 0;
20 }
View Code

 

hdu 2031

进制转化,将十进制转成其他进制,水

 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5     int n,i,len,j,count;
 6     char a[1000];
 7     while(scanf("%d",&n)!=EOF)
 8     {
 9         getchar();
10         for (i=1;i<=n;i++)
11         {
12             count=0;
13             gets(a);
14             len=strlen(a);
15             for (j=0;j<len;j++) if (a[j]<0) count++;
16             printf("%d\n",count/2);
17         }
18     }
19     return 0;
20 }
View Code

 

hdu 2032

输出杨辉三角,水

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int n,i,j;
 5     while(scanf("%d",&n)!=EOF)
 6     {
 7         int a[30][30];
 8         for (i=0;i<n;i++)
 9         {
10             a[i][0]=1;
11             a[i][i]=1;
12         }
13         for (i=2;i<n;i++)
14             for (j=1;j<i;j++) a[i][j]=a[i-1][j-1]+a[i-1][j];
15         for (i=0;i<n;i++)
16         {
17             for (j=0;j<=i;j++)
18             {
19                 printf("%d",a[i][j]);
20                 if (j==i) printf("\n");
21                 else printf(" ");
22             }
23         }
24         printf("\n");
25     }
26     return 0;
27 }
View Code

 

hdu 2033

两时间相加,水

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int n,i;
 5     while(scanf("%d",&n)!=EOF)
 6     {
 7         for (i=1;i<=n;i++)
 8         {
 9             long long AH,AM,AS,BH,BM,BS,H,M,S;
10             scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&AH,&AM,&AS,&BH,&BM,&BS);
11             S=AS+BS;
12             M=AM+BM;
13             H=AH+BH;
14             if (S>=60)
15             {
16                 S-=60;
17                 M++;
18             }
19             if (M>=60)
20             {
21                 M-=60;
22                 H++;
23             }
24             printf("%I64d %I64d %I64d\n",H,M,S);
25         }
26     }
27     return 0;
28 }
View Code

 

hdu 2034

求两集合差集,水

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int n,i;
 5     while(scanf("%d",&n)!=EOF)
 6     {
 7         for (i=1;i<=n;i++)
 8         {
 9             long long AH,AM,AS,BH,BM,BS,H,M,S;
10             scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&AH,&AM,&AS,&BH,&BM,&BS);
11             S=AS+BS;
12             M=AM+BM;
13             H=AH+BH;
14             if (S>=60)
15             {
16                 S-=60;
17                 M++;
18             }
19             if (M>=60)
20             {
21                 M-=60;
22                 H++;
23             }
24             printf("%I64d %I64d %I64d\n",H,M,S);
25         }
26     }
27     return 0;
28 }
View Code