Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <stdio.h>
- #include <iomanip>
- #include <math.h>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int a,b,c,n,m,i,j,s1=0,s2=0;
- int A[100][100];
- ifstream f1;
- f1.open("c:\\temp\\Filemas1_3.txt");
- f1>>m>>n;
- if(n==0)
- {n=1;}
- if(m==0)
- {m=1;}
- {for(i=0;i<m;i++)
- {for(j=0;j<n;j++)
- f1>>A[i][j];
- }
- }
- f1.close();
- {for(i=0;i<m;i++)
- {for(j=0;j<n;j++)
- cout<<setw(2)<<A[i][j]<<" ";
- cout<<endl;
- }
- }
- ofstream f2;
- f2.open("C:\\temp\\Filemas2_0.txt");
- for(int i=0;i<m;i++)
- {
- for(int j=0;j<n;j++){
- f2<<setw(3)<<A[i][j]<<" ";}
- f2<<endl;
- }
- f2.close();
- if(m==1)
- {
- ofstream f3;
- f3.open("C:\\temp\\Filemas3_0.txt");
- cout<<"\n Функция №2:\n";
- {for(i=0;i<m;i++)
- {for(j=0;j<n;j++)
- cout<<setw(2)<<A[i][j]<<" ";
- cout<<endl;
- }
- }
- cout<<"\n Нечетные элементы:\n";
- {for(i=0;i<m;i++)
- {for(j=0;j<n;j++)
- if(A[i][j]%2!=0)
- {
- cout<<setw(2)<<A[i][j]<<" ";
- }
- }
- }
- for(int i=0;i<m;i++)
- {
- for(int j=0;j<n;j++){
- f3<<setw(2)<<A[i][j]<<" ";}
- f3<<endl;
- }
- f3.close();
- }
- if(n==1)
- {
- ofstream f4;
- f4.open("C:\\temp\\Filemas3_0.txt");
- cout<<"\n Функция №2:\n";
- for(int i=0;i<m;i++)
- {
- for(int j=0;j<n;j++)
- }
- if(A[i][j]%2)=0
- {for(i=0;i<m;i++)
- {for(j=0;j<n;j++)
- cout<<setw(2)<<A[i][j]<<" ";
- cout<<endl;
- }
- }
- {for(i=0;i<m;i++)
- {for(j=0;j<n;j++)
- }
- }
- if(A[i][j]%2)=0
- f4<<setw(2)<<A[i][j]<<" ";
- f4.close();
- }
- if((m!=1)&&(n!=1))
- {
- ofstream f5;
- f5.open("C:\\temp\\Filemas3_0.txt");
- cout<<"\n Введите 2 числа:\n";
- cin>>a>>b;
- if (a<b)
- {
- c=b;
- }
- else
- c=a;
- {for(i=0;i<m;i++)
- {for(j=0;j<n;j++)
- if(A[i][j]<c)
- {
- A[i][j]= A[i][j]*A[i][j]
- }
- cout<<setw(2)<<A[i][j]<<" ";
- }
- }
- {for(i=0;i<m;i++)
- {for(j=0;j<n;j++)
- if(A[i][j]<c)
- {
- A[i][j]= A[i][j]*A[i][j]
- }
- f5<<setw(2)<<A[i][j]<<" ";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement