- 1
Дан целочисленный массив. Вычислить сумму положительных элементов
Задача на C++. Дан целочисленный массив. Вычислить сумму положительных элементов. С вводом массива. Помогите с задачей
7 Antworten
+ 2
What have you done so far?
+ 2
I would normally say: this is not a homework-providing service. Please make some effort and we will help you with the rest.
But ok, here is an example
int sum=0;
int arr[10]={1,-2,-3,18,4,-5,7,11,-8,5};
for (int i=0;i<10;i++){
if( arr[i] > 0)
sum+=arr[i];
}
cout<<sum<<endl;
+ 2
Lol, you are killing me.
int arr[10];
for (int i = 0; i < 10; i++) {
cin >> arr[i];
}
+ 1
Thank you very much
- 1
nothing
- 1
thank you very much. one request how to implement input
- 3
I am very sorry. How to connect these two codes?