Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main(){
- int broj, sumap=0, pron=1, ap[10], an[10], bp=0, bn=0;
- do{
- cin>>broj;
- if(broj%2==0){
- sumap=sumap+broj;
- ap[bp]=broj;
- bp++;
- }
- else{
- pron=pron*broj;
- an[bn]=broj;
- bn++;
- }
- }while(sumap<=pron && bp+bn<10);
- for(int i=0; i<bp-1; i++){
- for(int j=i+1; j<bp; j++){
- if(ap[i]>ap[j])
- swap(ap[i], ap[j]);
- }
- }
- cout<<endl;
- for(int i=0; i<bn-1; i++){
- for(int j=i+1; j<bn; j++){
- if(an[i]<an[j])
- swap(an[i], an[j]);
- }
- }
- if(bn>0)
- cout<<"proizvod neparnih je: "<<pron<<endl;
- else
- cout<<"nema neparnih brojeva"<<endl;
- if(bn>0)
- cout<<"suma parnih je: "<<sumap<<endl;
- else
- cout<<"nema parnih brojeva"<<endl;
- for(int i=0; i<bp; i++)
- cout<<ap[i]<<" ";
- cout<<endl;
- for(int i=0; i<bn; i++)
- cout<<an[i]<<" ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement