Guest User

Untitled

a guest
Apr 6th, 2015
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4. int m, n;
  5. cout << "vvedi chislo strok "; cin >> n ;
  6. int **array = new int*[n];
  7. cout << "vvedi chislo stolbcov "; cin >> m;
  8.  
  9. for (int i = 0; i < n; i++)
  10. array[i] = new int[m];
  11.  
  12. for (int i = 0; i < n; i++)
  13. for (int j = 0; j < m; j++)
  14. cin >> *(*(array + i) + j);
  15.  
  16. for (int i = 0; i < n; i++){
  17. for (int j = 0; j < m; j++)
  18. {
  19. cout.width(3);
  20. cout << *(*(array + i) + j);
  21. }cout << endl;
  22. }
  23.  
  24. int prev = 0;
  25. for (int i = 0; i < n; i++){
  26. for (int j = 0; j < m; j++)
  27. prev += *(*(array + i) + j);
  28. break;
  29. }
  30. cout << "summa pervogo ryada=" << prev;
  31. int now;
  32. cout << "check";
  33. for (int i = 1; i < n; i++)
  34. {
  35. int now = 0; cout << "now=" << now << endl;
  36. for (int j = 0; j < m; j++){
  37. now += *(*(array + i) + j); cout << "now=" << now << endl;
  38. if (now < prev) {
  39. int *p = *(*(array + i) + j);
  40. *(*(array + i - 1) + j) = *(*(array + i) + j);
  41. *(*(array + i) + j) = *p;
  42. prev = now;
  43. }
  44. }
  45.  
  46. }
  47. cout << "ny zarabotaj zhe :)" << endl;
  48. for (int i = 0; i < n; i++){
  49. for (int j = 0; j < m; j++)
  50. {
  51. cout.width(3);
  52. cout << *(*(array + i) + j);
  53. }cout << endl;
  54. system("pause");
  55. }
Advertisement
Add Comment
Please, Sign In to add comment