Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- void nuskaitymas(int &n);
- int dRieksme(int &n);
- void Del(int n, int maxIndex);
- int A[100][100];
- int main() {
- int n;
- nuskaitymas(n);
- dRieksme(n);
- cin >> n;
- return 0;
- }
- void nuskaitymas(int &n) {
- ifstream fd("Duomenys.txt");
- ofstream fr("Rezultatai.txt");
- fd >> n;
- for(int i = 0; i < n;i++) {
- for (int j = 0; j < n; j++) {
- fd >> A[i][j];
- fr << A[i][j] << " ";
- cout << A[i][j] << " ";
- }
- cout << endl;
- fr << endl;
- }
- fr << endl;
- }
- int dRieksme(int &n) {
- int max = INT_MIN;
- int maxIndex = 0;
- for(int i = 1; i < n;i++) {
- for (int j = n-i; j < n; j++) {
- if(A[i][j] > max) {
- max = A[i][j];
- maxIndex = i;
- }
- }
- }
- cout << "didziausias ksaicius " << max << " jo eilute yra " << maxIndex+1;
- Del(n, maxIndex);
- return 0;
- }
- void Del(int n, int maxIndex) {
- ofstream fr("Rezultatai.txt", ios::app);
- for(int i = 0; i < n;i++) {
- for (int j = 0; j < n; j++) {
- if (i != maxIndex) {
- fr << A[i][j] << " ";
- }
- }
- if (i != maxIndex) {
- fr << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement