Repository navigation
Expand file tree
/
Copy pathdummy.cpp
More file actions
120 lines (98 loc) · 2.21 KB
/
Copy pathdummy.cpp
File metadata and controls
120 lines (98 loc) · 2.21 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include<iostream>
#include<vector>
#include<unordered_map>
#include<string>
using namespace std;
// // // int main(){
// // // int arr[]= { 1,2,2,3,1,4,2};
// // // int n=sizeof(arr)/sizeof(arr[0]);
// // // unordered_map<int,int>freq;
// // // for(int i=0;i<n;i++){
// // // freq[arr[i]]++;
// // // }
// // // for(auto x : freq){
// // // cout<<x.first<<"-> "<<x.second<<endl;
// // // }
// // // return 0;
// // // }
// // string onlyNumber(string s){
// // string result =" ";
// // for(int i=0;i<s.length(); i++){
// // if(isdigit(s[i] )){
// // result+=s[i];
// // }
// // }
// // return result;
// // }
// // int main(){
// // string s;
// // cin>>s;
// // cout<<onlyNumber(s)<<endl;
// // return 0;
// // }
// // class Node{
// // public:
// // int data;
// // Node* next;
// // Node(int val){
// // data= val;
// // next=NULL;
// // }
// // };
// int solve(int n, vector<int>& dp) {
// if(n <= 2) return n;
// if(dp[n] != -1) return dp[n];
// return dp[n] = solve(n-1, dp) + solve(n-2, dp);
// }
// int climbStairs(int n) {
// vector<int> dp(n+1, -1);
// return solve(n, dp);
// }
// int main(){
// int ans= climbStairs(5);
// cout<< ans << endl;
//}
// star pattern
void printStar(int n){
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
if(i == n || i == 1 || j == n || j == 1)
cout<<"* ";
else {
cout<<" ";
}
}
cout<<endl;
}
}
void printStar2(int n){
for(int i=1; i<=n; i++){
for(int j=1; j<=n -i;j++){
cout<<" ";
}
for(int j=1 ;j<= (2*i -1); j++ ){
cout<<"*";
}
cout << endl;
}
}
void printstar3(int n ){
int p =n;
for(int i = 1; i <= n; i++) {
// spaces
// stars
for(int j = 1; j <= i; j++) {
cout << p ;
}
p=p-1;
cout << endl;
}
}
int main(){
// string s= "suraj yadav";
// cout<< s.size()<<endl;
// for(char ch : s){
// }
printstar3(4);
return 0;
}