Commits

liangsdu  committed 4018749

introduction to ACM newbie

  • Participants

Comments (0)

Files changed (2)

File introduction/1000.c

+/** A + B problem **/
+#include <stdio.h>
+int main()
+{
+    int a, b;
+    while(scanf("%d%d", &a, &b) != EOF)	//while(scanf("%d%d", &a, &b) == 2)
+        printf("%d\n", a + b);
+    return 0;
+}

File introduction/1001.c

+/** hdoj 1001, sum problem **/
+#include <stdio.h>
+int main()
+{
+    int n;
+    while(scanf("%d", &n) == 1)
+        if(n%2 == 0)
+            printf("%d\n\n",n/2*(n+1));
+        else
+            printf("%d\n\n",(n+1)/2*n);
+
+    return 0;
+}