Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. #include <graphics.h>
  5. using namespace std;
  6. ifstream in("date.in");
  7. ifstream f("date1.in");
  8. struct info
  9. {
  10. char nume[100];
  11. int x,y,c,m,cb;
  12. };
  13. struct cafenea
  14. {
  15. char categ[30],tip[30];
  16. int cant,pret;
  17. };
  18. info t[50];
  19. void citire(info t[],int &n)
  20. {
  21. in>>n;
  22. for(int i=0;i<n;i++)
  23. {
  24. in.get();
  25. in.getline(t[i].nume,30);
  26. in>>t[i].x>>t[i].y>>t[i].c>>t[i].cb>>t[i].m;
  27. }
  28. }
  29. void afisbuton(info A,int dx,int dx1)
  30. {
  31. setcolor(A.c);
  32. setfillstyle(1,A.cb);
  33. bar(A.x-dx,A.y-textheight("A")/2,A.x+dx+textwidth(A.nume),A.y+3*textheight("A")/2);
  34. //bar(A.x-dx,A.y-textheight("A")/2,A.x-dx+dx1,A.y+3*textheight("A")/2);
  35. setbkcolor(A.cb);
  36. settextstyle(1,0,A.m);
  37. outtextxy(A.x,A.y,A.nume);
  38. }
  39. void inverseaza(info &A,int dx,int dx1)
  40. {
  41. int aux=A.c;
  42. A.c=A.cb;
  43. A.cb=aux;
  44. afisbuton(A,dx,dx1);
  45. }
  46. void afisare(info t[],int n,int dx,int dx1)
  47. {
  48. for(int i=0;i<n;i++)
  49. {
  50. afisbuton(t[i],dx,dx1);
  51. }
  52. }
  53. int animatie(info t[],int n,int &ba)
  54. {
  55. char car;
  56. int dx,dx1;
  57. dx=10;
  58. dx1=100;
  59. afisare(t,n,dx,dx1);
  60. inverseaza(t[ba],dx,dx1);
  61. do
  62. {
  63. car=getch();
  64. if(car=='s')
  65. {
  66. inverseaza(t[ba],dx,dx1);
  67. ba=(ba+1)%n;
  68. afisbuton(t[ba],dx,dx1);
  69. }
  70. else
  71. if(car=='w')
  72. {
  73. inverseaza(t[ba],dx,dx1);
  74. ba--;
  75. if(ba==-1)
  76. ba=n-1;
  77. afisbuton(t[ba],dx,dx1);
  78. }
  79. }while(car!='v');
  80. return ba;
  81. }
  82. void optiune0()
  83. {
  84. int k=initwindow(500,500,"text",0,0);
  85. outtextxy(50,50,"rezolvarea 0");
  86. getch();
  87. closegraph(k);
  88. }
  89. void optiune1()
  90. {
  91. int k=initwindow(500,500,"text",60,60);
  92. outtextxy(50,50,"rezolvarea 1");
  93. getch();
  94. closegraph(k);
  95. }
  96. void meniu(info t[],int n)
  97. {
  98. int opt;
  99. int ba=0;
  100. do
  101. {
  102. opt=animatie(t,n,ba);
  103. switch(opt)
  104. {
  105. case 0:optiune0();break;
  106. case 1:optiune1();break;
  107. }
  108. }while(opt!=n-1);
  109. }
  110. int main()
  111. {
  112. int d,m,n,p,dx,dx1;
  113. dx=10;
  114. dx1=150;
  115. info b;
  116. strcpy(b.nume,"testare");
  117. b.x=100;
  118. b.y=200;
  119. b.c=7;
  120. b.cb=10;
  121. b.m=2;
  122. citire(t,n);
  123. detectgraph(&d,&m);
  124. initgraph(&d,&m,"");
  125. initwindow(getmaxwidth(),getmaxheight(),"text",0,0);
  126. //afisbuton(b,10,150);
  127. //delay(600);
  128. //inverseaza(b,10,150);
  129. //afisare(t,n,dx,dx1);
  130. //animatie(t,n);
  131. meniu(t,n);
  132. while(!kbhit());
  133. closegraph();
  134. return 0;
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement