Advertisement
Guest User

zdania7_problem19

a guest
Dec 5th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <cmath>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8. // ввод
  9. int n,m,x;
  10. cout<<"n = ";
  11. cin >> n;
  12. cout<<"m = ";
  13. cin >>m;
  14. cout<<"x = ";
  15. cin>>x;
  16. cout << "vvedite massiv a " << endl;
  17. int **a = new int*[n * 2];
  18. for (int i = 0; i < n; i++){
  19. a[i] = new int[m * 2];
  20. for (int j = 0; j < n; j++){
  21. cin >> a[i][j];
  22. }
  23. }
  24. // тело программы
  25. for(int j= 0; j<m;j++){
  26. int summa = 0;
  27. for(int i=0;i<n;i++){
  28. summa = summa+a[i][j];
  29. }
  30. if(summa==x){
  31. for(int u=0;u<n;u++){
  32. for(int g=j;g < m - 1;g++){
  33. a[u][g]=a[u][g+1];
  34. }
  35. }
  36. m--;
  37. j--;
  38. }
  39.  
  40. }
  41. // вывод массива
  42. cout << endl;
  43. cout << "Otvet:" << endl;
  44. for (int i = 0; i < n; i++){
  45. for (int j = 0; j < m ; j++){
  46. cout << a[i][j] << ' ';
  47. }
  48. cout << endl;
  49. }
  50. system("pause");
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement