Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- void citire(int &n, int &m, int a[][50])
- {
- do
- {
- cout << "n="; cin >> n;
- cout << "m="; cin >> m;
- } while (n < 3 || n>100);
- cout << "dati elementele matricei:";
- for (int i = 0; i < n; i++)
- for (int j = 0; j < m; j++)
- cin >> a[i][j];
- }
- bool exista(int a[][50], int n, int m,int x)
- {
- int i = 0;
- for (int j = 0; j < m; j++)
- if (a[i][j] == x)
- return true;
- int j = n - 1;
- for (int i = 0; i < n; i++)
- if (a[i][j] == x)
- return true;
- i = n - 1;
- for (int j = 0; j < m; j++)
- if (a[i][j] == x)
- return true;
- j = 0;
- for (int i = 0; i < n; i++)
- if (a[i][j] == x)
- return true;
- return false;
- }
- int main()
- {
- int a[50][50], n, m, x;
- citire(n, m, a);
- cout << "x="; cin >> x;
- if (exista(a, n, m, x))
- cout << "da";
- else
- cout << "nu";
- cout << endl << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement