Bob103

для френда

Dec 22nd, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int **creat(int &n, int &m)
  4. {
  5. int **mas = new int*[n];
  6. for (int i = 0; i < n; ++i)
  7. mas[i] = new int[m];
  8. for (int i = 0; i < n; ++i)
  9. for (int j = 0; j < m; ++j)
  10. {
  11. cout << "mas[" << i << "][" << j << "]="; cin >> mas[i][j];
  12. }
  13. return mas;
  14. }
  15. int main()
  16. {
  17. int n, m,masj,mas1;
  18. cout << "n="; cin >> n; cout << "m="; cin >> m;
  19. int **a = creat(n, m);
  20. for (int i = 0; i < n; ++i)
  21. {
  22. mas1 = a[i][0];
  23. masj = 0;
  24. for (int j = 0; j < m; ++j)
  25. {
  26. if (a[i][j] != mas1)
  27. masj=j;
  28.  
  29. }
  30.  
  31. }
  32. cout << "Received matrix:"<<endl;
  33. for (int i = 0; i<n; i++)
  34. {
  35. for (int j = 0; j<m; j++)
  36. cout <<masj<< " ";
  37. cout << endl;
  38. }
  39. for (int i = 0; i <n; ++i)
  40. delete[]a[i];
  41. delete[]a;
  42. system("pause");
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment