Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstring>
- #include <graphics.h>
- using namespace std;
- ifstream in("date.in");
- ifstream f("date1.in");
- struct info
- {
- char nume[100];
- int x,y,c,m,cb;
- };
- struct cafenea
- {
- char categ[30],tip[30];
- int cant,pret;
- };
- info t[50];
- void citire(info t[],int &n)
- {
- in>>n;
- for(int i=0;i<n;i++)
- {
- in.get();
- in.getline(t[i].nume,30);
- in>>t[i].x>>t[i].y>>t[i].c>>t[i].cb>>t[i].m;
- }
- }
- void afisbuton(info A,int dx,int dx1)
- {
- setcolor(A.c);
- setfillstyle(1,A.cb);
- bar(A.x-dx,A.y-textheight("A")/2,A.x+dx+textwidth(A.nume),A.y+3*textheight("A")/2);
- //bar(A.x-dx,A.y-textheight("A")/2,A.x-dx+dx1,A.y+3*textheight("A")/2);
- setbkcolor(A.cb);
- settextstyle(1,0,A.m);
- outtextxy(A.x,A.y,A.nume);
- }
- void inverseaza(info &A,int dx,int dx1)
- {
- int aux=A.c;
- A.c=A.cb;
- A.cb=aux;
- afisbuton(A,dx,dx1);
- }
- void afisare(info t[],int n,int dx,int dx1)
- {
- for(int i=0;i<n;i++)
- {
- afisbuton(t[i],dx,dx1);
- }
- }
- int animatie(info t[],int n,int &ba)
- {
- char car;
- int dx,dx1;
- dx=10;
- dx1=100;
- afisare(t,n,dx,dx1);
- inverseaza(t[ba],dx,dx1);
- do
- {
- car=getch();
- if(car=='s')
- {
- inverseaza(t[ba],dx,dx1);
- ba=(ba+1)%n;
- afisbuton(t[ba],dx,dx1);
- }
- else
- if(car=='w')
- {
- inverseaza(t[ba],dx,dx1);
- ba--;
- if(ba==-1)
- ba=n-1;
- afisbuton(t[ba],dx,dx1);
- }
- }while(car!='v');
- return ba;
- }
- void optiune0()
- {
- int k=initwindow(500,500,"text",0,0);
- outtextxy(50,50,"rezolvarea 0");
- getch();
- closegraph(k);
- }
- void optiune1()
- {
- int k=initwindow(500,500,"text",60,60);
- outtextxy(50,50,"rezolvarea 1");
- getch();
- closegraph(k);
- }
- void meniu(info t[],int n)
- {
- int opt;
- int ba=0;
- do
- {
- opt=animatie(t,n,ba);
- switch(opt)
- {
- case 0:optiune0();break;
- case 1:optiune1();break;
- }
- }while(opt!=n-1);
- }
- int main()
- {
- int d,m,n,p,dx,dx1;
- dx=10;
- dx1=150;
- info b;
- strcpy(b.nume,"testare");
- b.x=100;
- b.y=200;
- b.c=7;
- b.cb=10;
- b.m=2;
- citire(t,n);
- detectgraph(&d,&m);
- initgraph(&d,&m,"");
- initwindow(getmaxwidth(),getmaxheight(),"text",0,0);
- //afisbuton(b,10,150);
- //delay(600);
- //inverseaza(b,10,150);
- //afisare(t,n,dx,dx1);
- //animatie(t,n);
- meniu(t,n);
- while(!kbhit());
- closegraph();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement