Advertisement
Guest User

arreasProg

a guest
Oct 31st, 2011
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <conio.h>
  3. using namespace std;
  4. int main() {
  5. int N, M, k;
  6. cout<<"Enter the size of arreas(2 numbers): "<<endl;
  7. cin>>N>>M;
  8. int mas[N][M], min, max, minI, maxI;
  9. //------------------------------------------------------------------------------
  10. for(int i=0; i<N; i++) {
  11. for(int j=0; j<M; j++) {
  12. cout<<"Enter arreas: "<<endl;
  13. cin>>mas[i][j]; } }
  14. max=mas[0][0];
  15. min=mas[0][0];
  16. //------------------------------------------------------------------------------
  17. for(int i=0; i<N; i++) {
  18. for(int j=0; j<M; j++) {
  19. if(mas[i][j]>max) {            
  20. max=mas[i][j];
  21. maxI=i; }
  22. if(mas[i][j]<min) {
  23. min=mas[i][j];
  24. minI=i; } } }
  25. //------------------------------------------------------------------------------
  26. for(int i=0; i<N; i++) {
  27. for(int j=0; j<M; j++) {
  28. k=mas[max][i];
  29. mas[max][i]=mas[min][i];
  30. mas[min][i]=k; } }
  31. cout<<"Masiv: "<<endl;
  32. //------------------------------------------------------------------------------
  33. for(int i=0; i<N; i++) {
  34. for(int j=0; j<M; j++) {
  35. cout<<mas[i][j]<<" "; } }
  36. cout<<endl<<"min = "<<min<<endl<<"max = "<<max<<endl<<"minI = "<<minI<<endl<<"maxI = "<<maxI<<endl;
  37. getch(); }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement