Првва П Првва Регистрация 27 Сен 2013 Сообщения 99 Репутация 0 Спасибо 0 Монет 0 28 Апр 2016 #1 Дан линейный массив чисел, определить что больше сумма четных номеров или не четных номеров.
lfvfcrec L lfvfcrec Регистрация 15 Фев 2013 Сообщения 97 Репутация 10 Спасибо 1 Монет 0 28 Апр 2016 #2 #include "iostream" #include "ctime" #include "cstdlib" using namespace std; int main(){ int const n=10; int a[n],odd=0,even=0; srand(time(0)); for(int i=0;i< n;i++)a=rand()%21-10; for(int i=0;i< n;i++)cout<< a<<; cout<<endl; for(int i=0;i< n;i++)i% 2?evendd+=a; cout<<"odd > even: "<<boolalpha<<(odd>even)<<endl; cin.get();} Позитивный голос 0
#include "iostream" #include "ctime" #include "cstdlib" using namespace std; int main(){ int const n=10; int a[n],odd=0,even=0; srand(time(0)); for(int i=0;i< n;i++)a=rand()%21-10; for(int i=0;i< n;i++)cout<< a<<; cout<<endl; for(int i=0;i< n;i++)i% 2?evendd+=a; cout<<"odd > even: "<<boolalpha<<(odd>even)<<endl; cin.get();}
Apupenchik A Apupenchik Регистрация 6 Апр 2013 Сообщения 102 Репутация 0 Спасибо 0 Монет 0 28 Апр 2016 #3 int sum_odd=0, summ=0; for(int i=0; i < n ; ++i) if( i % 2 == 0 ) summ+=a; else summ_odd+=a; if(summ > summ_odd) printf("more chet"); else printf ("more nechet"); Позитивный голос 0
int sum_odd=0, summ=0; for(int i=0; i < n ; ++i) if( i % 2 == 0 ) summ+=a; else summ_odd+=a; if(summ > summ_odd) printf("more chet"); else printf ("more nechet");