Advertisement
Guest User

oopsie

a guest
Sep 12th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. //Wczytujemy 10 elementow do tablicy
  5. //Liczymy srednia i ja wyswietlamy
  6. //Wyswietl wszystkie wieksze od sredniej
  7.  
  8. int main(int argc, char** argv) {
  9.  
  10. float a,suma=0,sr=0,sumax=0,srx=0;
  11. int t[10],i,i2,k;
  12. cout<<"Wpisuj kolejne liczby do tablicy."<<endl;
  13.  
  14. for(i=0; i<=9; i++)
  15. {
  16. cout<<"Podaj liczbe: ";
  17. cin>>t[i];
  18. suma=suma+t[i];
  19. k++;
  20. if(t[i]==0)
  21. {
  22. break;
  23. }
  24. }
  25. if(i==0)
  26. {
  27. cout<<"Podanych liczb: "<<i<<endl;
  28. return 0;
  29. }
  30.  
  31. i2=i;
  32.  
  33. cout<<"Suma wynosi:"<<suma<<endl;
  34. sr=suma/i;
  35. cout<<"Srednia wynosi:"<<sr<<endl;
  36.  
  37. cout<<"Liczby wieksze od sredniej: ";
  38. do{
  39. if(t[i]>sr)
  40. {
  41. cout<<t[i]<<" ";
  42. }
  43. i--;
  44. }while(i>0);
  45.  
  46. i=0;
  47.  
  48. cout<<endl<<"Suma 1 i ostatniego elementu:";
  49. sumax=t[0]+t[i2-1];
  50. cout<<" "<<sumax;
  51.  
  52. cout<<endl<<"Srednia 1 i ostatniego elementu";
  53. srx=sumax/2;
  54. cout<<" "<<srx;
  55.  
  56. // cout<<endl<<"Elementy podzielne przez 3 z nieparzystymi indeksami"<<endl;
  57.  
  58. cout<<endl<<"Elementy podzielne przez 3:";
  59.  
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement