Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int v_i = 0, v_j = 0, s = 0, lin, col;
  9. int ghinde[3][3] = {{ 0, 4, 1 }, { 0, 1, 1 }, { 1, 0, 1 } };
  10. lin = 2; col = 2;
  11. while (v_i != 2 || v_j != 2)
  12. {
  13. if (v_i == lin)
  14. {
  15. s += ghinde[v_i][v_j + 1];
  16. cout << s << endl;
  17. v_j++;
  18. }
  19. else
  20. if (v_j == col)
  21. {
  22. s += ghinde[v_i + 1][v_j];
  23. cout << s << endl;
  24. v_i++;
  25. }
  26. else
  27. if (ghinde[v_i][v_j + 1] > ghinde[v_i + 1][v_j])
  28. {
  29. s += ghinde[v_i][v_j + 1];
  30. cout << s << endl;
  31. v_j++;
  32. }
  33. else
  34. {
  35. s += ghinde[v_i + 1][v_j];
  36. cout << s << endl;
  37. v_i++;
  38. }
  39. }
  40. cout << "Numar ghinde adunate: " << s << endl;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement