Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct nod
- {
- int info;
- nod *adr;
- };
- void citire( nod *&p, int n )
- {
- int i;
- nod *c;
- if( p == NULL )
- p = new nod;
- cin >> p->info;
- p->adr = NULL;
- for ( i = 2 ; i <= n ; ++i )
- {
- c = new nod;
- c->adr=p;
- cin >> c->info;
- p = c;
- }
- }
- void addfst( nod *&p, int x )
- {
- nod *a;
- a = new nod;
- a -> info = x;
- a -> adr = p;
- p = a;
- }
- void addlst( nod *p, int x )
- {
- nod *a, *c;
- a = new nod;
- a -> info = x;
- a -> adr = NULL;
- c = p;
- while( c->adr != NULL )
- c = c->adr;
- c -> adr = a;
- }
- void afisare( nod *p )
- {
- while( p != NULL )
- {
- cout << p->info << " ";
- p = p->adr;
- }
- }
- int verif( nod *p )
- {
- int flag = 1;
- int minim = p->info;
- while( p != NULL )
- {
- if( p->info < minim)
- flag = 0;
- p=p->adr;
- }
- return flag;
- }
- int main()
- {
- int i, n;
- nod *p;
- cin >> n;
- citire(p, n);
- afisare(p);
- cout << "\n";
- cout << verif(p);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement