-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeeksForGeeks_Special_Pattern.py
More file actions
80 lines (69 loc) · 1.67 KB
/
Copy pathGeeksForGeeks_Special_Pattern.py
File metadata and controls
80 lines (69 loc) · 1.67 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# We are about to print pattern like this below:
G
G e
G e e
G e e k
G e e k s
G e e k s F
G e e k s F o
G e e k s F o r
G e e k s F o r G
G e e k s F o r G e
G e e k s F o r G e e
G e e k s F o r G e e k
G e e k s F o r G e e k s
# For this problem you need to think the logic on your on, and I must say that you can not find solution to this pattern anywhere on any website including GeeksForGeeks as well.
I will update the solution for this problem tomorrow.
---------------------Program: C++ ----------------------------------
#include <iostream>
using namespace std;
int main() {
string name;
cout << "Type your name: ";
cin >> name;
cout << "Your name is: " << name;
for(int i = 0; i < name.length()+1; i++){
for(int j = 1; j < i+1; j++){
cout<< name[j-1]<< " ";
}
cout << "" << endl;
}
return 0;
}
-----------------------Output : C++ -------------------------------
Type your name: GEEKSFORGEEKS
Your name is: GEEKSFORGEEKS
G
G E
G E E
G E E K
G E E K S
G E E K S F
G E E K S F O
G E E K S F O R
G E E K S F O R G
G E E K S F O R G E
G E E K S F O R G E E
G E E K S F O R G E E K
G E E K S F O R G E E K S
----------------------- Program : Python3 -------------------------
l = [x for x in 'GEEKSFORGEEKS']
print(l)
for i in range(0,len(l),1):
for j in range(1,i+2):
print(l[j-1], end=" ")
print(" ")
---------------------- Output : Python3 ---------------------------
G
G E
G E E
G E E K
G E E K S
G E E K S F
G E E K S F O
G E E K S F O R
G E E K S F O R G
G E E K S F O R G E
G E E K S F O R G E E
G E E K S F O R G E E K
G E E K S F O R G E E K S