GerexD

ism4--1

Sep 24th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <limits.h>
  3. /**
  4. 1. Adott egy n x m-es mátrix. Határozzuk meg:
  5. a) az összes elemének az összegét
  6. b) a k. oszlop legkisebb elemét
  7. c) a mátrix legnagyobb elemét
  8. d) írjuk ki a mátrix páratlan sorait
  9. e) minden oszlop legnagyobb elemét*/
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14. int a[50][50],n,m,o=0,k,min=INT_MAX,max=INT_MIN;
  15. cout<<"N ";cin>>n;
  16. cout<<"M ";cin>>m;
  17. cout<<"K ";cin>>k;
  18.  
  19. for(int i=1;i<=n;i++)
  20. {
  21. for(int j=1;j<=m;j++)
  22. cin>>a[i][j];
  23. }
  24. for(int i=1;i<=n;i++)
  25. {
  26. for(int j=1;j<=m;j++)
  27. if(j==k && a[i][j]<min) min=a[i][j];
  28. }
  29. cout<<"K oszlop legkisebb eleme:"<<min<<endl;
  30. for(int i=1;i<=n;i++)
  31. {
  32. for(int j=1;j<=m;j++)
  33. if(a[i][j]>max) max=a[i][j];
  34. }
  35. cout<<"A legnagyobb elem:"<<max<<endl;
  36. cout<<endl;
  37. for(int i=1;i<=n;i++)
  38. {
  39. for(int j=1;j<=m;j++)
  40. if(i%2==1)cout<<a[i][j]<<" ";
  41. cout<<endl;
  42. }
  43.  
  44. return 0;
  45. }
Add Comment
Please, Sign In to add comment