Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main(){
- int m, n;
- cout << "vvedi chislo strok "; cin >> n ;
- int **array = new int*[n];
- cout << "vvedi chislo stolbcov "; cin >> m;
- for (int i = 0; i < n; i++)
- array[i] = new int[m];
- for (int i = 0; i < n; i++)
- for (int j = 0; j < m; j++)
- cin >> *(*(array + i) + j);
- for (int i = 0; i < n; i++){
- for (int j = 0; j < m; j++)
- {
- cout.width(3);
- cout << *(*(array + i) + j);
- }cout << endl;
- }
- int prev = 0;
- for (int i = 0; i < n; i++){
- for (int j = 0; j < m; j++)
- prev += *(*(array + i) + j);
- break;
- }
- cout << "summa pervogo ryada=" << prev;
- int now;
- cout << "check";
- for (int i = 1; i < n; i++)
- {
- int now = 0; cout << "now=" << now << endl;
- for (int j = 0; j < m; j++){
- now += *(*(array + i) + j); cout << "now=" << now << endl;
- if (now < prev) {
- int *p = *(*(array + i) + j);
- *(*(array + i - 1) + j) = *(*(array + i) + j);
- *(*(array + i) + j) = *p;
- prev = now;
- }
- }
- }
- cout << "ny zarabotaj zhe :)" << endl;
- for (int i = 0; i < n; i++){
- for (int j = 0; j < m; j++)
- {
- cout.width(3);
- cout << *(*(array + i) + j);
- }cout << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment