-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathV-1.cpp
More file actions
69 lines (61 loc) · 1.41 KB
/
Copy pathV-1.cpp
File metadata and controls
69 lines (61 loc) · 1.41 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
#include <iostream>
#include <conio.h>
using namespace std;
class TButton{
public:
char name[50];
int index;
int fg,bg;
TButton(int i=1,int f=96,int b=40){
index=i;
fg=f;
bg=b;
}
void Name(char *n,int i){
for(int I=0;I<i;I++){
name[I]=n[I];
}
}
};
int function(int x , int y){
//5 menu options
int no=5;
TButton A[no];
char a[8]="OPTION1";
char b[8]="OPTION2";
char c[8]="OPTION3";
char d[8]="OPTION4";
char e[8]="OPTION5";
A[0].Name(a,8);
A[1].Name(b,8);
A[2].Name(c,8);
A[3].Name(d,8);
A[4].Name(e,8);
static int count=1;
char M;
while(1){
for(int i=0;i<no;i++){
if(i+1!=count){
printf("\033[0m\033[%d;%dm\033[%d;%dH %s \n",A[i].fg,A[i].bg,i+1+y,x,A[i].name);
}
else{
printf("\033[0m\033[%d;%dm\033[%d;%dH %s \n",106,97,i+1+y,x,A[i].name);
}
}
M=getch();
if(M=='w'||M=='W'){count--;}
else if(M=='s'||M=='S'){count++;}
else if(M=='e'||M=='E'){break;}
if(count<1){
count=no;
}
else if(count>no){
count=1;
}
}
return count;
}
int main(){
printf("\n\n%d",function(1,1));
return 0;
}