-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
122 lines (112 loc) · 1.73 KB
/
main.cpp
File metadata and controls
122 lines (112 loc) · 1.73 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
121
122
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
using namespace std;
int w, h, lw, ttp, c;
string st="*";
void drawtriangle()
{
int CASE;
srand(time(0));
CASE = rand() % 2 + 1;
if(CASE==1){
for(int i=0; i<=7; i++){
for(int j=1; j<=i; j++){
cout<<st;
}
cout<<""<<endl;
}
}
if(CASE==2){
for(int i=0; i<7; i++){
for(int j=0; j<i; j++){
cout<<" ";
}
for(int l=7; l>=i; l--){
cout<<st;
}
cout<<""<<endl;
}
}
}
void drawline()
{
int CASE;
srand(time(0));
CASE = rand() % 2 + 1;
if(CASE==1){
for(int i=0; i<lw+1; i++)
cout<<st;}
if(CASE==2){
for(int i=0; i<lw+1; i++)
cout<<st<<endl;}
}
void draw()
{
for(int i=0; i<w+1; i++) //width
cout<<st;
cout<<endl;
for(int i=0; i<h; i++){ //height
for(int j=0; j<w; j++){
if(j==0 || j==w-1)
cout<<st;
cout<<" ";
}
cout<<""<<endl;
}
for(int i=0; i<w+1; i++) //also width
cout<<st;
cout<<endl;
}
void geometry()
{
if(w==h)
cout<<"Square ("<<"S="<<""<<w*h<<")"<<endl;
if(w>h||w<h)
cout<<"Rectangle ("<<"S="<<""<<w<<"*"<<h<<"="<<w*h<<")"<<endl;
}
int choice()
{
cout<<"(Enter a number)Draw: "<<endl;
cout<<"1. Square"<<endl;
cout<<"2. Line"<<endl;
cout<<"3. Triangle"<<endl;
cout<<"4. Customize figure border"<<endl;
cout<<"5. Exit"<<endl;
cin>>c;
if(c==4){
cout<<"Enter a symbol:";
cin>>st;
st=st[0];
cout<<"Draw:";
cin>>c;
}
return 0;
}
int main()
{
while(c!=1&&c!=2&&c!=3){
choice();
if(c==1){
cout<<"Enter width: ";
cin>>w;
cout<<"Enter height: ";
cin>>h;
draw();
geometry();}
if(c==2){
cout<<"Enter line width: ";
cin>>lw;
drawline();
}
if(c==3){
drawtriangle();
}
if(c==5){
exit(0);
}
if(c>5)
cout<<"invalid choice"<<endl;
}
}