-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXsquare.cpp
52 lines (46 loc) · 1.14 KB
/
Xsquare.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
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int x = 0;
int y = 0;
int size;
int need = 1;
while(need == 1){
cout << "Enter size : ";
cin >> size;
y = size - 3;
for(int i = 0; i < size; i++){
cout << "*";
}
cout << endl;
for(int a = 0; a < (size - 2); a++){
cout << "*";
for(int b = 0; b < (size - 2); b++){
if(x == b) cout << "*";
if(y == b && (a !=(int)(size/2 - 1) || 0 == size%2)) cout << "*";
if(x != b && y != b) cout << " ";
}
cout << "*";
x = x + 1;
y = y - 1;
cout << endl;
}
if(size != 1){
for(int i = 0; i < size; i++){
cout << "*";
}
cout << endl;
}
do {
cout << "Need more? (1/0) : ";
cin >> need;
if(need != 1 && need != 0) cout << "Error" << endl;
} while (need != 1 && need != 0);
x = 0;
y = 0;
}
system("PAUSE");
return EXIT_SUCCESS;
}