-
Notifications
You must be signed in to change notification settings - Fork 16
/
7.c
45 lines (40 loc) · 867 Bytes
/
7.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
int main()
{
int i, j, value = 1;
printf("Program A:\n");
for (i = 1; i <= 13; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d ", value++);
}
printf("\n");
}
printf("\nProgram B:\n");
for (i = 1; i <= 13; i++)
{
if (i % 2 != 0)
{
for (j = 1; j <= i; j++)
{
if (j % 2 == 0)
printf("0 ");
else
printf("1 ");
}
}
else
{
for (j = 1; j <= i; j++)
{
if (j % 2 == 0)
printf("1 ");
else
printf("0 ");
}
}
printf("\n");
}
return 0;
}