Skip to content

Instantly share code, notes, and snippets.

@zuigon
Created December 10, 2013 15:10
Show Gist options
  • Save zuigon/7892131 to your computer and use it in GitHub Desktop.
Save zuigon/7892131 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cstdio>
using namespace std;
int main (int argc, char const* argv[])
{
// 2x4
int m[2][4];
for(int i=0; i<2; ++i)
for(int j=0; j<4; ++j)
cin>>m[i][j];
for(int i=0; i<4; ++i){
for(int j=0; j<2; ++j)
printf("%4d", m[j][i]);
cout<<endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main (int argc, char const* argv[])
{
int m, n, M[11][11];
in_m:
cout<<"m: "; cin>>m;
if(!(0<m && m<11)) goto in_m;
in_n:
cout<<"n: "; cin>>n;
if(!(0<n && n<11)) goto in_n;
for(int i=0; i<m; ++i){
cout<<i+1<<". redak: ";
for(int j=0; j<n; ++j)
cin>>M[i][j];
}
int mm=M[0][0];
for(int i=0; i<m; ++i)
for(int j=0; j<n; ++j)
if(M[i][j]<mm)
mm = M[i][j];
cout<<"Najmanja vrijednost: "<<mm<<endl;
return 0;
}
#include <iostream>
#include <cstdio>
using namespace std;
int main (int argc, char const* argv[])
{
int m, n,
M1[11][11],
M2[11][11];
in_m:
cout<<"m: "; cin>>m;
if(!(1<m && m<6)) goto in_m;
in_n:
cout<<"n: "; cin>>n;
if(!(2<n && n<11)) goto in_n;
cout<<"# Unos 1. matrice:"<<endl;
for(int i=0; i<m; ++i){
cout<<i+1<<". redak: ";
for(int j=0; j<n; ++j)
cin>>M1[i][j];
}
cout<<"# Unos 2. matrice:"<<endl;
for(int i=0; i<m; ++i){
cout<<i+1<<". redak: ";
for(int j=0; j<n; ++j)
cin>>M2[i][j];
}
for(int i=0; i<m; ++i)
for(int j=0; j<n; ++j)
M1[i][j]-=M2[i][j];
cout<<"# A - B ="<<endl;
for(int i=0; i<m; ++i){
for(int j=0; j<n; ++j)
printf("%3d", M1[i][j]);
cout<<endl;
}
return 0;
}
#include <iostream>
#include <cstdio>
using namespace std;
int main (int argc, char const* argv[])
{
int n, mmax, mmin,
M[11][11];
in_n:
cout<<"n: "; cin>>n;
if(!(1<n && n<11)) goto in_n;
cout<<"# Unos 1. matrice:"<<endl;
for(int i=0; i<n; ++i){
cout<<i+1<<". redak: ";
for(int j=0; j<n; ++j)
cin>>M[i][j];
}
mmin=M[0][n-1];
mmax=M[0][0];
for(int i=0; i<n; ++i)
if(M[i][i]<mmin)
mmax=M[i][n-i-1];
for(int i=0; i<n; ++i)
if(M[i][i]>mmax)
mmax=M[i][i];
cout<<"mmin, mmax: ("<<mmin<<", "<<mmax<<")"<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment