Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- int main()
- {
- int v_i = 0, v_j = 0, s = 0, lin, col;
- int ghinde[3][3] = {{ 0, 4, 1 }, { 0, 1, 1 }, { 1, 0, 1 } };
- lin = 2; col = 2;
- while (v_i != 2 || v_j != 2)
- {
- if (v_i == lin)
- {
- s += ghinde[v_i][v_j + 1];
- cout << s << endl;
- v_j++;
- }
- else
- if (v_j == col)
- {
- s += ghinde[v_i + 1][v_j];
- cout << s << endl;
- v_i++;
- }
- else
- if (ghinde[v_i][v_j + 1] > ghinde[v_i + 1][v_j])
- {
- s += ghinde[v_i][v_j + 1];
- cout << s << endl;
- v_j++;
- }
- else
- {
- s += ghinde[v_i + 1][v_j];
- cout << s << endl;
- v_i++;
- }
- }
- cout << "Numar ghinde adunate: " << s << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement