Commits

liangsdu  committed b8ed004

解决所有的introduction问题,大部分是格式问题,入门水题

  • Participants
  • Parent commits 4018749

Comments (0)

Files changed (11)

+# ignore file for Mercurial
+# synatx: glob	(shell-style) or regexp
+
+syntax: glob
+
+*~
+*.swp
+*.exe
+*.obj
+*.o
+notes/*

File introduction/1089.c

+/** hdoj 1089: A+B for Input-Output Practice (I)
+Sample Input
+1 5
+10 20
+Sample Output
+6
+30
+**/
+#include <stdio.h>
+int main(void)
+{
+    int a, b;
+    while(scanf("%d %d", &a, &b) != EOF)
+        printf("%d\n",a+b);
+
+    return 0;
+}

File introduction/1090.c

+/** hdoj 1090: A+B for Input-Output Practice (II)
+Sample Input
+2
+1 5
+10 20
+Sample Output
+6
+30
+**/
+#include <stdio.h>
+int main(void)
+{
+    int n, i;
+    scanf("%d", &n);
+    for(i=0; i<n; i++)
+    {
+        int a, b;
+        scanf("%d %d", &a, &b);
+        printf("%d\n",a+b);
+    }
+    return 0;
+}

File introduction/1091.c

+/** hdoj 1091: A+B for Input-Output Practice (III)
+Sample Input
+1 5
+10 20
+0 0
+Sample Output
+6
+30
+**/
+#include <stdio.h>
+int main(void)
+{
+    int a, b;
+    while(scanf("%d %d", &a, &b), a||b)
+        printf("%d\n",a+b);
+
+    return 0;
+}

File introduction/1092.c

+/** hdoj 1092: A+B for Input-Output Practice (IV)
+Sample Input
+4 1 2 3 4
+5 1 2 3 4 5
+0
+Sample Output
+10
+15
+**/
+#include <stdio.h>
+int main(void)
+{
+    int n, i, a, sum;
+    while(scanf("%d", &n), n)
+    {
+        sum = 0;
+        for(i=0; i<n; i++)
+        {
+            scanf("%d", &a);
+            sum = sum + a;
+        }
+        printf("%d\n", sum);
+    }
+
+    return 0;
+}

File introduction/1093.c

+/** hdoj 1093: A+B for Input-Output Practice (V)
+Sample Input
+2
+4 1 2 3 4
+5 1 2 3 4 5
+Sample Output
+10
+15
+**/
+#include <stdio.h>
+int main(void)
+{
+    int n;
+    scanf("%d", &n);
+    int i, j, num, a, sum;
+    for(i=0; i<n; i++)
+    {
+        sum = 0;
+        scanf("%d", &num);
+        for(j=0; j<num; j++)
+        {
+            scanf("%d", &a);
+            sum = sum + a;
+        }
+        printf("%d\n", sum);
+    }
+
+    return 0;
+}

File introduction/1094.c

+/** hdoj 1094: A+B for Input-Output Practice (VI)
+Sample Input
+4 1 2 3 4
+5 1 2 3 4 5
+Sample Output
+10
+15
+**/
+#include <stdio.h>
+int main(void)
+{
+    int n, i, a, sum;
+    while(scanf("%d", &n) != EOF)
+    {
+        sum = 0;
+        for(i=0; i<n; i++)
+        {
+            scanf("%d", &a);
+            sum = sum + a;
+        }
+        printf("%d\n", sum);
+    }
+
+    return 0;
+}

File introduction/1095.c

+/** hdoj 1095: A+B for Input-Output Practice (VII)
+    multiple test cases
+Sample Input
+1 5
+10 20
+Sample Output
+6
+
+30
+**/
+#include <stdio.h>
+int main(void)
+{
+    int a, b;
+    while(scanf("%d %d", &a, &b) != EOF)
+        printf("%d\n\n", a+b);
+
+    return 0;
+}

File introduction/1096.c

+/** hdoj 1096: A+B for Input-Output Practice (VIII)
+ע�������ʽ
+Sample Input
+3
+4 1 2 3 4
+5 1 2 3 4 5
+3 1 2 3
+Sample Output
+10
+
+15
+
+6
+**/
+#include <stdio.h>
+int main(void)
+{
+    int n, i, j, a, num, sum;
+    scanf("%d", &n);
+    for(i=0; i<n; i++)
+    {
+        scanf("%d", &num);
+        sum = 0;
+        for(j=0; j<num; j++)
+        {
+            scanf("%d", &a);
+            sum = sum + a;
+        }
+        printf("%d\n", sum);
+        if(i != (n-1))
+            printf("\n");
+    }
+
+    return 0;
+}

File introduction/1161.c

+/** hdoj 1161: Eddy's mistakes
+大小写转换: A(65)  ->  a(97) or tolower(char)
+Sample Input
+weLcOmE tO HDOj Acm 2005!
+Sample Output
+welcome to hdoj acm 2005!
+**/
+
+#define NUM 1000
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+    char line[NUM+1];
+    while(fgets(line, NUM, stdin) != NULL)
+/**  while(scanf("%s", line) != EOF)    **/
+    {
+        int i;
+        for(i=0; i<strlen(line); i++)
+        {
+            while(line[i]>='A' && line[i] <= 'Z')
+                line[i] = line[i] + 32;
+        }
+        fprintf(stdout, "%s", line);
+    }
+    return 0;
+}

File introduction/1406.c

+/** HDOJ 1406: 完数
+完数的定义:如果一个大于1的正整数的所有因子之和等于它的本身,则称这个数是完数,比如6,28都是完数:6=1+2+3;28=1+2+4+7+14。
+本题的任务是判断两个正整数之间完数的个数。备注:需考虑两数大小
+**/
+#include <stdio.h>
+#include <math.h>
+
+int is_perfect(int num)
+{
+    int i;
+    int sum=0;
+    for(i=1; i<(num/2 + 1); i++)
+        if(num%i == 0)
+            sum = sum + i;
+    if( sum == num)
+        return 1;
+
+    return 0;
+}
+
+int main()
+{
+    int i, n;
+    scanf("%d", &n);
+    for(i=0; i<n; i++)
+    {
+        int a, b, j;
+        int k=0;
+        scanf("%d %d", &a, &b);
+        int max = a>b?a:b;
+        int min = a<b?a:b;
+        for(j=min; j<=max; j++)
+        {
+            if(is_perfect(j) == 1)
+                k++;
+        }
+        printf("%d\n", k);
+    }
+
+    return 0;
+}