-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_loop and count.cpp
66 lines (53 loc) · 1.33 KB
/
3_loop and count.cpp
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
//
// Created by Daisy on 2020/10/13.
//
# include "iostream"
#include <string>
using std::cin; using std::endl;
using std::cout;using std::string;
int loop_greetings()
{
cout << "please input your name";
string name;
cin >> name;
cout << "please input the pad size you want";
int pad = 0;
cin >> pad;
const string greetings = "Hello, " + name + "!";
const int rows = pad*2 + 3;
const string::size_type cols = greetings.size() + pad*2 + 2;
cout << endl;
for(int r = 0; r!=rows; ++r){
string::size_type c = 0;
while (c!=cols){
if(r==pad+1 && c == pad+1){
cout << greetings;
c += greetings.size();
}else{
if(c == 0 || c == cols-1 || r == 0 || r == rows -1)
cout << "*";
else
cout << " ";
++c;
}
}
cout << endl;
}
return 0;
}
int bigger()
{
int number1, number2;
cout << "please input 2 numbers";
cin >> number1 >> number2;
if(number2<number1){
cout << number1 << " is bigger than " << number2;
}
else if(number2 == number1){
cout << number1 << " is the same with " << number2;
}
else{
cout << number2 << " is bigger than " << number1;
}
cout << endl;
}