Commit 41b933e73fbf1dca04d99f53a387b6ce1fc93e34

Authored by Changtong Qiu
1 parent 87c302b629
Exists in master

Junk Remove

Showing 2 changed files with 0 additions and 44 deletions Side-by-side Diff

1   -#include <stdio.h>
2   -
3   -int main() {
4   - int n = 0,
5   - temp = 0,
6   - sum = 0;
7   - char c;
8   -
9   - printf("Integer: ");
10   - if (scanf("%d%c%d", &n, &c, &temp) <= 2 || n <= 0) {
11   - printf("Invalid number!\n");
12   - return 1;
13   - }
14   - else
15   - temp = n;
16   -
17   -
18   - do {
19   - sum += temp % 10;
20   - temp /= 10;
21   - } while (temp);
22   -
23   - printf("Digit-sum of %d = %d\n", n, sum);
24   - return 0;
25   -}
1   -#include <stdio.h>
2   -
3   -int main() {
4   - int rows = 0;
5   -
6   - printf("Number of rows: ");
7   - scanf("%d", rows);
8   -
9   - for (int i = 1; i <= &rows; i++) {
10   - for (int j = 1; j <= rows-i; j++)
11   - putchar(' ');
12   - for (int j = i; j <= 2*i - 1; j++)
13   - printf("%d", j);
14   - for (int j = 2*i - 2; j >= i; j--)
15   - printf("%d", j);
16   - putchar('\n');
17   - }
18   - return 0;
19   -}