Skip to content

Commit cb655db

Browse files
committed
Change: Changed C/28.preIncrement/, C/29.reverseNum/
1 parent fd5e3e2 commit cb655db

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

C/28.preIncrement/preIncrement.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "../shit.h"
2+
3+
int main(void)
4+
{
5+
int i = 0;
6+
int sum = 0;
7+
int num, tmp;
8+
9+
printf("How many integers do you want to enter?"); scanf("%d", &num);
10+
11+
while (i < num)
12+
{
13+
printf("No.%d:", ++i); scanf("%d", &tmp);
14+
sum += tmp;
15+
}
16+
17+
printf("Sum is %d, average is %.2f.\n", sum, (double)sum / num);
18+
19+
printf("Press any key to continue.\n"); getchar();
20+
21+
return 0;
22+
}

C/29.reverseNum/reverseNum.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "../shit.h"
2+
3+
int main(void)
4+
{
5+
int no;
6+
7+
do
8+
{
9+
printf("Enter a positive integer:"); scanf("%d", &no);
10+
11+
if (no <= 0)
12+
puts("\aDo not enter a negative integer or 0! Fuck you.");
13+
} while (no <= 0);
14+
15+
printf("The reverse of num is ");
16+
while (no > 0)
17+
{
18+
printf("%d", no % 10);
19+
no /= 10;
20+
}
21+
puts(".");
22+
23+
return 0;
24+
}

0 commit comments

Comments
 (0)