Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<conio.h>
- using namespace std;
- void CreearePadure(int ghinde[3][3]) {
- int ghinde[3][3] = {
- { 0, 4, 1 },
- { 0, 1, 1 },
- { 1, 0, 1 },
- };
- }
- void AfisarePadure(int ghinde[3][3]) {
- int i, j;
- for (i = 0;i < 3;i++) {
- for (j = 0;j < 3;j++)
- cout << ghinde[i][j] << " ";
- cout << endl;
- }
- }
- void CautareGhinde(int ghinde[3][3]) {
- int i, j, ii = 0, jj = 0, NumarGhinde = 0;
- i = 3;
- j = 3;
- while (ii != 3 || jj != 3)
- {
- if (ii == i)
- {
- NumarGhinde = NumarGhinde + ghinde[ii][jj + 1];
- j++;
- }
- else
- if (jj == j)
- {
- NumarGhinde = NumarGhinde + ghinde[ii + 1][jj];
- ii++;
- }
- else
- if (ghinde[ii][jj + 1] > ghinde[ii + 1][jj])
- {
- NumarGhinde = NumarGhinde + ghinde[ii][jj + 1];
- jj++;
- }
- else
- {
- NumarGhinde = NumarGhinde + ghinde[ii + 1][jj];
- i++;
- }
- }
- cout << "Numar ghinde adunate: " << NumarGhinde;
- }
- int main() {
- int ghinde[3][3];
- CreearePadure(ghinde);
- AfisarePadure(ghinde);
- VanatoareGhinde(ghinde);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement