Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, i;
- float a;
- bool flag=0;
- setlocale(LC_ALL, "rus");
- cout<<"Введите количество переменных N: ";
- cin>>n;
- if(n<=0)
- {
- cout<<"Размерность массива должна быть больше 0!!!"<<endl;
- system("pause");
- }
- else
- {
- float*mas = new float[n];
- cout<<"Введите а: ";
- cin>>a;
- cout<<"Введите x1<=x2<=...<=xn"<<endl;
- for(i=0; i<n; i++) //заполнение массива
- {
- cout<<"a["<<i+1<<"] = ";
- cin>>mas[i];
- cout<<endl;
- if(i>0)
- {
- if(mas[i]<mas[i-1])
- {
- cout<<"Введите x1<=x2<=...<=xn!!!"<<endl;
- system("pause");
- return 0;
- }
- }
- }
- for(i=0; i<n; i++) //присоединение "а" к новой последовательности
- {
- if(a>=mas[i]&&flag==0)cout<<mas[i]<<" ";
- else
- if(flag==0)
- {
- flag=1;
- cout<<a<<" ";
- }
- if(flag==1)
- cout<<mas[i]<<" ";
- }
- cout<<endl;
- delete[]mas;
- system("pause");
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement