Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- int i,j,a[10][10],n,m,v[10],totalsir=0,k,x=1;
- bool gasit;
- fstream in("amat.in.txt",ios::in);
- fstream out("amat.out.txt",ios::out);
- in >> n;
- in >> m;
- for(i=1;i<=n;i++){
- for(j=1;j<=m;j++){
- in >> a[i][j];
- }
- }
- for(i=1;i<=n;i++){
- for(j=1;j<=m;j++){
- out << a[i][j] << " ";
- }
- out << endl;
- }
- for(i=1;i<=n;i++){
- for(j=1;j<=m;j++){
- gasit = false;
- for(k=1;k<=totalsir;k++){
- if (v[k]==a[i][j]) {
- gasit = true;
- break;
- }
- }
- if (!gasit) {
- v[x++]=a[i][j];
- totalsir++;
- }
- }
- }
- int contor, elemmaxim, maximcontor=0,i1=0,i2,j1,j2;
- cout << endl;
- for(k=1;k<=totalsir;k++) {
- contor = 0;
- for(i=1;i<=n;i++){
- for(j=1;j<=m;j++){
- if (a[i][j]==v[k]){
- contor++;
- }
- if (contor >= maximcontor){
- maximcontor = contor;
- elemmaxim =v[k];
- }
- }
- }
- }
- for(i=1;i<=n;i++){
- for(j=1;j<=m;j++){
- if(a[i][j]==elemmaxim){
- if(i1==0){
- i1=i;
- j1=j;
- }
- i2=i;
- j2=j;
- }
- }
- }
- out << endl;
- out << i1 << " " << j1 << " " << i2 << " " << j2<<endl;
- out << endl;
- //cout << "Cel mai smec numar:"<<elemmaxim<<" si sunt " << maximcontor;
- int operatii,minim;
- in >> operatii;
- in >> minim;
- for (k=1;k<=operatii;k++){
- in >> i1;
- in >> j1;
- in >> i2;
- in >> j2;
- in >> x;
- for(i=i1;i<=i2;i++){
- for(j=j1;j<=j2;j++){
- a[i][j]+=x;
- }
- }
- for(i=1;i<=n;i++){
- for(j=1;j<=m;j++){
- out << a[i][j] << " ";
- }
- out <<endl;
- }
- out <<endl;
- }
- in.close();
- contor =0;
- for(i=1;i<=n;i++){
- for(j=1;j<=m;j++){
- if (a[i][j]<6)
- contor++;
- }
- }
- if(contor==0)
- out << "Nu mai avem nevoie de operatii pentru matrice.\n";
- else out << "Mai avem nevoie de " << contor << " operatii pentru matrice\n";
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement