на С++ как то так
#include<iostream>#include<ctime>
using namespace std;
int main(){ srand(time(NULL)); int N, a, sum = 0, ten = 10, index = 0; int *arr; cout << "enter size of arr(enter N) : "; cin >> N; arr = new int [N]; for(int i = 1; i <= N;i++) arr[i] = rand()%25;
cout << "arr : " << endl; for(int i = 1; i <= N;i++) cout << arr[i] << " " ; cout << endl;
cout << "enter a : " ; cin >> a;
for(int i = 1; i <= N;i++) { if(arr[i] == a) index = i;
} if(index != 0) { for(int i = index + 1; i <= N;i++) sum = sum + arr[i]; } if(sum == 0) cout << "Result = " << ten << endl; else cout << "Result = " << sum << endl; }
на С++ как то так
#include<iostream>
#include<ctime>
using namespace std;
int main(){
srand(time(NULL));
int N, a, sum = 0, ten = 10, index = 0;
int *arr;
cout << "enter size of arr(enter N) : ";
cin >> N;
arr = new int [N];
for(int i = 1; i <= N;i++)
arr[i] = rand()%25;
cout << "arr : " << endl;
for(int i = 1; i <= N;i++)
cout << arr[i] << " " ;
cout << endl;
cout << "enter a : " ;
cin >> a;
for(int i = 1; i <= N;i++)
{
if(arr[i] == a)
index = i;
}
if(index != 0)
{
for(int i = index + 1; i <= N;i++)
sum = sum + arr[i];
}
if(sum == 0)
cout << "Result = " << ten << endl;
else
cout << "Result = " << sum << endl;
}