fork download
  1. void Canvas::Wypelniacz()
  2. {
  3. std::stack<QPair <int, int> > stos;
  4. QPair<int, int> start = qMakePair(xw ,yw);
  5. stos.push(start);
  6. QPair<int, int> xy;
  7. QColor old_color = kolortla;
  8. QColor target_color = colorgr1;
  9. while (!stos.empty()) {
  10. //std::cout << stos.top().first << ", " << stos.top().second << std::endl;
  11. xy = stos.top();
  12. stos.pop();
  13. if ((xy.first >=0 && xy.first < image.width()) && (xy.second >=0 && xy.second < image.height()))
  14. image.setPixel(xy.first,xy.second, target_color.rgb());
  15. if ((xy.first-1) >= 0)
  16. if ((image.pixel(xy.first-1,xy.second) == old_color.rgb())) stos.push(qMakePair(xy.first-1,xy.second));
  17. if ((xy.first+1) < image.width())
  18. if ((image.pixel(xy.first+1,xy.second) == old_color.rgb())) stos.push(qMakePair(xy.first+1,xy.second));
  19. if ((xy.second-1) >= 0)
  20. if ((image.pixel(xy.first,xy.second-1) == old_color.rgb())) stos.push(qMakePair(xy.first,xy.second-1));
  21. if ((xy.second+1) < image.height())
  22. if ((image.pixel(xy.first,xy.second+1) == old_color.rgb())) stos.push(qMakePair(xy.first,xy.second+1));
  23. }
  24. repaint();
  25. wsp.clear();
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:6: error: ‘Canvas’ has not been declared
 void Canvas::Wypelniacz()
      ^
prog.cpp: In function ‘void Wypelniacz()’:
prog.cpp:3:5: error: ‘stack’ is not a member of ‘std’
     std::stack<QPair <int, int> > stos;
     ^
prog.cpp:3:16: error: ‘QPair’ was not declared in this scope
     std::stack<QPair <int, int> > stos;
                ^
prog.cpp:3:23: error: expected primary-expression before ‘int’
     std::stack<QPair <int, int> > stos;
                       ^
prog.cpp:3:23: error: expected ‘;’ before ‘int’
prog.cpp:4:11: error: expected primary-expression before ‘int’
     QPair<int, int> start = qMakePair(xw ,yw);
           ^
prog.cpp:4:11: error: expected ‘;’ before ‘int’
prog.cpp:5:5: error: ‘stos’ was not declared in this scope
     stos.push(start);
     ^
prog.cpp:5:15: error: ‘start’ was not declared in this scope
     stos.push(start);
               ^
prog.cpp:6:11: error: expected primary-expression before ‘int’
     QPair<int, int> xy;
           ^
prog.cpp:6:11: error: expected ‘;’ before ‘int’
prog.cpp:7:5: error: ‘QColor’ was not declared in this scope
     QColor old_color = kolortla;
     ^
prog.cpp:7:12: error: expected ‘;’ before ‘old_color’
     QColor old_color = kolortla;
            ^
prog.cpp:8:12: error: expected ‘;’ before ‘target_color’
     QColor target_color = colorgr1;
            ^
prog.cpp:11:9: error: ‘xy’ was not declared in this scope
         xy = stos.top();
         ^
prog.cpp:13:41: error: ‘image’ was not declared in this scope
         if ((xy.first >=0 && xy.first < image.width()) && (xy.second >=0 && xy.second < image.height()))
                                         ^
prog.cpp:14:48: error: ‘target_color’ was not declared in this scope
             image.setPixel(xy.first,xy.second, target_color.rgb());
                                                ^
prog.cpp:16:18: error: ‘image’ was not declared in this scope
             if ((image.pixel(xy.first-1,xy.second) == old_color.rgb())) stos.push(qMakePair(xy.first-1,xy.second));
                  ^
prog.cpp:16:55: error: ‘old_color’ was not declared in this scope
             if ((image.pixel(xy.first-1,xy.second) == old_color.rgb())) stos.push(qMakePair(xy.first-1,xy.second));
                                                       ^
prog.cpp:16:113: error: ‘qMakePair’ was not declared in this scope
             if ((image.pixel(xy.first-1,xy.second) == old_color.rgb())) stos.push(qMakePair(xy.first-1,xy.second));
                                                                                                                 ^
prog.cpp:17:28: error: ‘image’ was not declared in this scope
         if ((xy.first+1) < image.width())
                            ^
prog.cpp:18:55: error: ‘old_color’ was not declared in this scope
             if ((image.pixel(xy.first+1,xy.second) == old_color.rgb())) stos.push(qMakePair(xy.first+1,xy.second));
                                                       ^
prog.cpp:18:113: error: ‘qMakePair’ was not declared in this scope
             if ((image.pixel(xy.first+1,xy.second) == old_color.rgb())) stos.push(qMakePair(xy.first+1,xy.second));
                                                                                                                 ^
prog.cpp:20:18: error: ‘image’ was not declared in this scope
             if ((image.pixel(xy.first,xy.second-1) == old_color.rgb())) stos.push(qMakePair(xy.first,xy.second-1));
                  ^
prog.cpp:20:55: error: ‘old_color’ was not declared in this scope
             if ((image.pixel(xy.first,xy.second-1) == old_color.rgb())) stos.push(qMakePair(xy.first,xy.second-1));
                                                       ^
prog.cpp:20:113: error: ‘qMakePair’ was not declared in this scope
             if ((image.pixel(xy.first,xy.second-1) == old_color.rgb())) stos.push(qMakePair(xy.first,xy.second-1));
                                                                                                                 ^
prog.cpp:21:29: error: ‘image’ was not declared in this scope
         if ((xy.second+1) < image.height())
                             ^
prog.cpp:22:55: error: ‘old_color’ was not declared in this scope
             if ((image.pixel(xy.first,xy.second+1) == old_color.rgb())) stos.push(qMakePair(xy.first,xy.second+1));
                                                       ^
prog.cpp:22:113: error: ‘qMakePair’ was not declared in this scope
             if ((image.pixel(xy.first,xy.second+1) == old_color.rgb())) stos.push(qMakePair(xy.first,xy.second+1));
                                                                                                                 ^
prog.cpp:24:13: error: ‘repaint’ was not declared in this scope
     repaint();
             ^
prog.cpp:25:5: error: ‘wsp’ was not declared in this scope
     wsp.clear();
     ^
stdout
Standard output is empty