Добавил:
Upload
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:16_II / упорядочен ли вектор
.cpp#include <iostream>
using namespace std;
struct List { int data;
List *next;};
void create_List (List *&nach, int n){
List *p;
nach=0;
for(int i=0; i<n;i++){
p=new List;
cin>>p->data;
p->next=nach;
nach=p;}
}
void pokaz_List(List *nach){
List *p;
p=nach;
bool t=true;
while (p!=0){
cout<<p->data<<" ";
p=p->next;}
}
bool upor_List(List *nach){
List *p;
p=nach;
bool t=true;
while((p->next!=NULL) && t)
{if (p->data > p->next->data)
t=false;
p=p->next;}
return t;}
void main(){
List *nach1;
int n;
cout<<"n=";
cin>>n;
create_List(nach1,n);
pokaz_List(nach1);
cout<<"vector-"<<upor_List(nach1);}
Соседние файлы в папке 16_II