Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main(){
  5. int broj, sumap=0, pron=1, ap[10], an[10], bp=0, bn=0;
  6.  
  7. do{
  8. cin>>broj;
  9.  
  10. if(broj%2==0){
  11. sumap=sumap+broj;
  12. ap[bp]=broj;
  13. bp++;
  14. }
  15.  
  16. else{
  17. pron=pron*broj;
  18. an[bn]=broj;
  19. bn++;
  20. }
  21.  
  22. }while(sumap<=pron && bp+bn<10);
  23.  
  24. for(int i=0; i<bp-1; i++){
  25. for(int j=i+1; j<bp; j++){
  26. if(ap[i]>ap[j])
  27. swap(ap[i], ap[j]);
  28. }
  29. }
  30. cout<<endl;
  31.  
  32. for(int i=0; i<bn-1; i++){
  33. for(int j=i+1; j<bn; j++){
  34. if(an[i]<an[j])
  35. swap(an[i], an[j]);
  36. }
  37. }
  38.  
  39. if(bn>0)
  40. cout<<"proizvod neparnih je: "<<pron<<endl;
  41. else
  42. cout<<"nema neparnih brojeva"<<endl;
  43.  
  44. if(bn>0)
  45. cout<<"suma parnih je: "<<sumap<<endl;
  46. else
  47. cout<<"nema parnih brojeva"<<endl;
  48.  
  49. for(int i=0; i<bp; i++)
  50. cout<<ap[i]<<" ";
  51. cout<<endl;
  52. for(int i=0; i<bn; i++)
  53. cout<<an[i]<<" ";
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement