Skip to content

Commit 16b96c8

Browse files
committed
This is another pattern
1 parent 1b844b7 commit 16b96c8

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

This is c code/16.c

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <stdio.h>
2+
int main(){
3+
int a ,b,row;
4+
printf("Enter number of rows: ");
5+
scanf("%d", &row);
6+
for (a=row; a>=1; --a) {
7+
for (b=1; b<=a; ++b)
8+
{ printf("%d ",b); }
9+
printf("\n");
10+
}
11+
// Enter number of rows: 6
12+
// 1 2 3 4 5 6
13+
// 1 2 3 4 5
14+
// 1 2 3 4
15+
// 1 2 3
16+
// 1 2
17+
// 1
18+
19+
20+
21+
22+
int rows, i, j, space;
23+
24+
printf("Enter number of rows: ");
25+
scanf("%d", &rows);
26+
for (i=rows; i>=1; --i) {
27+
for (space=0; space<rows-i; ++space)
28+
printf(" ");
29+
for (j=i; j<=2*i-1; ++j)
30+
printf("* ");
31+
for (j=0; j<i-1; ++j)
32+
printf("* ");
33+
printf("\n");}
34+
35+
// Enter number of rows: 5
36+
// * * * * * * * * *
37+
// * * * * * * *
38+
// * * * * *
39+
// * * *
40+
// *
41+
42+
43+
}

This is c code/199.c

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
int a ,b;
3+
printf("Enter number of rows: ");
4+
scanf("%d", &rows);
5+
for (a=rows; a>=1; --a) {
6+
for (b=1; b<=a; ++b)
7+
{ printf("%d ",b); }
8+
printf("\n");
9+
}
10+
11+
12+
int rows, i, j, space;
13+
14+
printf("Enter number of rows: ");
15+
scanf("%d", &rows);
16+
for (i=rows; i>=1; --i) {
17+
for (space=0; space<rows-i; ++space)
18+
printf(" ");
19+
for (j=i; j<=2*i-1; ++j)
20+
printf("* ");
21+
for (j=0; j<i-1; ++j)
22+
printf("* ");
23+
printf("\n");
24+
}
25+
int rows, coef=1, space, i, j;
26+
printf("Enter number of rows: ");
27+
scanf("%d", &rows);
28+
for (i=0; i<rows; i++) {
29+
for (space=1; space <= rows-i; space++)
30+
printf(" ");
31+
for (j=0; j<=i; j++) {
32+
if (j==0 || i==0)
33+
coef = 1;
34+
else
35+
coef=coef*(i-j+1)/j;
36+
printf("%4d", coef);
37+
}
38+
printf("\n");
39+
}
40+
41+
int rows, i, j, number= 1;
42+
printf("Enter number of rows: ");
43+
scanf("%d", &rows);
44+
for (i=1; i<=rows; i++) {
45+
for (j=1; j<=i; ++j)
46+
{ printf("%d ", number);
47+
++number;
48+
}
49+
printf("\n");
50+
}
51+
52+
}*/

0 commit comments

Comments
 (0)