Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5.  
  6. // P=piros Z=zöld B=barna
  7. // L=pirosbarna(barna de yg pirosat már rá festettek)
  8. // K=zöldbarna
  9.  
  10.  
  11.  
  12.  
  13. void tolt(char x[],int i ){
  14.  
  15. for (int j =0;j<=i;j++){
  16.  
  17. x[j]='F'; //AZ EGÉSZ FEHÉR
  18. }
  19. }
  20.  
  21.  
  22. void festes (char x ,char y [],int j){
  23. //
  24. // BARNA KÉSZITÉS
  25. //
  26. if (x!=y[j] &&( y[j] =='P' || y[j]=='Z') ){ // KÜLÖNBÖZŐ SZINNEL FESTÜNK
  27.  
  28. y[j] ='B';
  29. return;
  30. }
  31. else if((y[j] == 'L' && x =='Z')|| (y[j] == 'K' && x =='P') ){
  32. y[j] = 'B';return;
  33. }
  34.  
  35. // ZÖLD KÉSZÍTÉS
  36.  
  37. if (y[j] =='F' && x =='Z' ){y[j] = 'Z';
  38. return;}
  39. else if (y[j] == 'K' && x =='Z'){y[j] ='Z';
  40. return;}
  41.  
  42. // PIROS KÉSZITÉS
  43.  
  44. if (y[j] =='F' && x == 'P' ){y[j] = 'P';return;}
  45. else if (y[j] == 'L' && x =='P'){y[j] ='P';return;}
  46.  
  47. //PIROSBARNA KÉSZITÉS
  48.  
  49. if (y[j] == 'B' && x == 'P'){y[j] ='L';return;}
  50.  
  51. //ZÖLDBARNA KÉSZITÉS
  52.  
  53. if (y[j] == 'B' && x == 'Z'){y[j] ='K';return;}
  54.  
  55. }
  56.  
  57. int szinezes (char x ){
  58.  
  59. if (x== 'Z'){
  60. return 'Z';
  61. }
  62. else if ( x == 'P'){
  63. return 'P';
  64. }
  65.  
  66. }
  67.  
  68. int main()
  69. {
  70. fstream f;
  71. int hossz;
  72. int ember;
  73. char szin; //SEGÉD VÁLTOZÓ , A BEOLVASÁS SORRENDJE MIATT
  74. int t[1]; // TÕL ÉS IG
  75. f.open("be1.txt",ios::in);
  76.  
  77. f>>hossz;
  78. f>>ember;
  79.  
  80. char A [hossz];
  81. tolt(A,hossz);
  82. for (int i =0; i<=ember ;i++){
  83.  
  84. f>>szin; //<---- ITT A PROBLÉMA
  85. f>>t[0];
  86. f>>t[1];
  87. cout << szin<< endl;
  88. for (int j = t[0];j<=t[1];j++){
  89.  
  90. festes(szinezes(szin),A,j);
  91. cout << t[0] << " " << t[1]<<endl;
  92.  
  93.  
  94. }
  95.  
  96. }
  97. f.close();
  98.  
  99.  
  100.  
  101.  
  102.  
  103. return 0;
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement