НАПИСАТЬ ПРОГРАММУ В dev-c++ Составить программу, формирующую одномерный массив, состоящий из N целых элементов. Вычислить сумму положительных элеменnов массива. Определить количество элементов, имеющих четные поряд- ковые номера и являющиеся нечетными числами. Упорядочить элементы массива по возрастанию.
int main(){ int N; cout<<"Enter the size of the array: "; cin>>N;
int arr[N]; int sum = 0; int count = 0; cout<<"Enter the elements of the array: "; for(int i=0; i<N; i++){ cin>>arr[i]; if(arr[i]>0){ sum += arr[i]; } if(i%2 == 1 && arr[i]%2 != 0){ count++; } } sort(arr, arr+N); cout<<"Sum of positive elements: "<<sum<<endl; cout<<"Number of elements with odd values at even indices: "<<count<<endl; cout<<"Sorted array: "; for(int i=0; i<N; i++){ cout<<arr[i]<<" "; } return 0;
using namespace std;
int main(){
int arr[N];int N;
cout<<"Enter the size of the array: ";
cin>>N;
int sum = 0;
int count = 0;
cout<<"Enter the elements of the array: ";
for(int i=0; i<N; i++){
cin>>arr[i];
if(arr[i]>0){
sum += arr[i];
}
if(i%2 == 1 && arr[i]%2 != 0){
count++;
}
}
sort(arr, arr+N);
cout<<"Sum of positive elements: "<<sum<<endl;
cout<<"Number of elements with odd values at even indices: "<<count<<endl;
cout<<"Sorted array: ";
for(int i=0; i<N; i++){
cout<<arr[i]<<" ";
}
return 0;
}