File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+ using namespace std ;
3+
4+ int main (){
5+
6+ // print all divisions
7+ int num = 36 ;
8+ vector <int > nums;
9+
10+ for (int i = 1 ; i <= sqrt (num); i++){
11+ if (num%i == 0 ){
12+ nums.emplace_back (i);
13+ if (num / i != i){ // for preventing double 6
14+ nums.emplace_back (num/i);
15+ }
16+ }
17+ }
18+
19+ sort (nums.begin (),nums.end ());
20+
21+ for (auto i : nums){
22+ cout << i << " " ;
23+ }
24+
25+ // 1 2 3 4 6 9 12 18 36
26+
27+ return 0 ;
28+ }
Original file line number Diff line number Diff line change 1+ // *
2+ // ***
3+ // *****
4+ // *******
5+ // *********
6+ // *******
7+ // *****
8+ // ***
9+ // *
10+
11+ #include < iostream>
12+
13+ using namespace std ;
14+
15+ int main () {
16+
17+ int r = 4 ;
18+ int c = 5 ;
19+ int space;
20+ int star;
21+ int opposite_r = r - 1 ;
22+
23+ for (int i = 0 ; i < r ; i++){
24+ space = r - i - 1 ;
25+ for (int j = 0 ; j < space ; j++){
26+ cout << " " ;
27+ }
28+
29+ star = (2 *i) + 1 ;
30+ for (int k = 0 ; k < star ; k++){
31+ cout << " *" ;
32+ }
33+
34+ cout << endl;
35+ }
36+
37+ for (int i = opposite_r - 1 ; i >= 0 ; i--){
38+ space = opposite_r - i;
39+ for (int j = 0 ; j < space; j++){
40+ cout << " " ;
41+ }
42+
43+ star = (2 *i) + 1 ;
44+ for (int k = 0 ; k < star ; k++){
45+ cout << " *" ;
46+ }
47+
48+ cout << endl;
49+ }
50+
51+ return 0 ;
52+ }
You can’t perform that action at this time.
0 commit comments