Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. void Funkcja(int n, int m, float **tab)
  7. {
  8. float temp, *temp1, *bucket=new float[m];
  9. for(int i=0; i<n; i++)
  10. {
  11. bucket[i]=0;
  12. for(int j=0; j<m ;j++) {bucket[i]+=tab[i][j]; }
  13. }
  14.  
  15.  
  16. for(int i=0;i<n;i++)
  17. for(int j=1;j<n-i;j++)
  18. if(bucket[j-1]<bucket[j])
  19. {
  20.  
  21. temp = bucket[j];
  22. bucket[j] = bucket[j-1];
  23. bucket[j-1] = temp;
  24.  
  25.  
  26. temp1 = tab[j];
  27. tab[j] = tab[j-1];
  28. tab[j-1] = temp1;
  29. }
  30.  
  31.  
  32. for(int i=0; i<3; i++)
  33. {
  34. //cout<<bucket[i]<<endl;
  35. for(int j=0; j<m; j++) {cout<<tab[i][j]<<" ";}
  36. cout<<endl;
  37. }
  38.  
  39. }
  40.  
  41. int main()
  42. {
  43. unsigned int n, m, p;
  44. cin>>n>>m>>p;
  45. float liczba;
  46. float **tab=new float*[m];
  47. for(int i=0; i<n; i++)
  48. {
  49. tab[i]=new float[n];
  50. for(int j=0; j<m; j++)
  51. {
  52. cin>>liczba;
  53. tab[i][j]=liczba;
  54. }
  55. }
  56. Funkcja(n, m, tab);
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement