#include "stdafx.h"
#include "iostream"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
setlocale(LC_ALL, "Russian");
const int SIZE = 10;
double arr[SIZE];
cout << "Введите " << SIZE << " чисел:" << endl;
for (int i=0; i<SIZE; i++)
cin >> arr[i];
int index = -1;
for (int i=SIZE-1; i>=0; i--)
if (arr[i] < 0)
index = i;
break;
}
if (index != -1)
int sum = 0;
for (int i=index+1; i<SIZE; i++)
sum = sum + arr[i];
cout << "Сумма " << sum << endl;
else
cout << "В массиве нет отрицательных элементов" << endl;
system("pause");
return 0;
3:
#include <iostream>
#include <cstdlib>
#define n 10
int main(){
int mas[n], max = -9999;
cout<<"Before :";
for(int i = 0; i < n; i++){
mas[i] = rand()% 50 + 1;
cout<<mas[i]<<" ";
if(mas[i] > max)
max = mas[i];
double tmp = max - (max * 0.2);
cout<<endl<<"Max = "<<max<<" tmp = "<<tmp<<endl<<"After: ";
for(int i = 0; i < n; i++)
if(mas[i] >= tmp)
if(!(mas[i] >= tmp))
#include "stdafx.h"
#include "iostream"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
setlocale(LC_ALL, "Russian");
const int SIZE = 10;
double arr[SIZE];
cout << "Введите " << SIZE << " чисел:" << endl;
for (int i=0; i<SIZE; i++)
cin >> arr[i];
int index = -1;
for (int i=SIZE-1; i>=0; i--)
if (arr[i] < 0)
{
index = i;
break;
}
if (index != -1)
{
int sum = 0;
for (int i=index+1; i<SIZE; i++)
sum = sum + arr[i];
cout << "Сумма " << sum << endl;
}
else
cout << "В массиве нет отрицательных элементов" << endl;
system("pause");
return 0;
}
3:
#include <iostream>
#include <cstdlib>
using namespace std;
#define n 10
int main(){
int mas[n], max = -9999;
cout<<"Before :";
for(int i = 0; i < n; i++){
mas[i] = rand()% 50 + 1;
cout<<mas[i]<<" ";
if(mas[i] > max)
max = mas[i];
}
double tmp = max - (max * 0.2);
cout<<endl<<"Max = "<<max<<" tmp = "<<tmp<<endl<<"After: ";
for(int i = 0; i < n; i++)
if(mas[i] >= tmp)
cout<<mas[i]<<" ";
for(int i = 0; i < n; i++)
if(!(mas[i] >= tmp))
cout<<mas[i]<<" ";
return 0;
}
#include "stdafx.h"
#include "iostream"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
setlocale(LC_ALL, "Russian");
const int SIZE = 10;
double arr[SIZE];
cout << "Введите " << SIZE << " чисел:" << endl;
for (int i=0; i<SIZE; i++)
cin >> arr[i];
int index = -1;
for (int i=SIZE-1; i>=0; i--)
if (arr[i] < 0)
{
index = i;
break;
}
if (index != -1)
{
int sum = 0;
for (int i=index+1; i<SIZE; i++)
sum = sum + arr[i];
cout << "Сумма " << sum << endl;
}
else
cout << "В массиве нет отрицательных элементов" << endl;
system("pause");
return 0;
}
3:
#include <iostream>
#include <cstdlib>
using namespace std;
#define n 10
int main(){
int mas[n], max = -9999;
cout<<"Before :";
for(int i = 0; i < n; i++){
mas[i] = rand()% 50 + 1;
cout<<mas[i]<<" ";
if(mas[i] > max)
max = mas[i];
}
double tmp = max - (max * 0.2);
cout<<endl<<"Max = "<<max<<" tmp = "<<tmp<<endl<<"After: ";
for(int i = 0; i < n; i++)
if(mas[i] >= tmp)
cout<<mas[i]<<" ";
for(int i = 0; i < n; i++)
if(!(mas[i] >= tmp))
cout<<mas[i]<<" ";
return 0;
}