You are on page 1of 5

//‫نيرمين عبد القدوس احمد المدني‬

//120200632004

#include <iostream>

#include<stdlib.h>

#include<conio.h>

#include<time.h>

Int one(int ar[],int ar2[])

Cout<<”index random \n\n”;

Cout<<”:0: “<<”| “<<ar[0]<<” |\n”;

Cout<<”:1: “<<”| “<<ar[1]<<” |\n”;

Cout<<”:2: “<<”| “<<ar[2]<<” |\n”;

Cout<<”:3: “<<”| “<<ar[3]<<” |\n”;

Cout<<”:4: “<<”| “<<ar[4]<<” |\n”;

Cout<<”:5: “<<”| “<<ar[5]<<” |\n”;

Cout<<”:6: “<<”| “<<ar[6]<<” |\n”;

Cout<<”:7: “<<”| “<<ar[7]<<” |\n”;

}
Int main()

{ int I,j;

Srand (time(0));

Int ar[8],ar2[8]={0},counter=0;

For( i=0;i<8;i++)

Ar[i]=rand()%31+10;

For( j=0;j<I;j++)

If(ar[i]==ar[j])

Counter++;

If(counter != 0)

i--;

counter=0;

One(ar,ar2);

////////////////////////////////////////////////////////////////////

Int search,temp;

Int n=0,m=0,s;

For(i=0;i<100 ;i++ )

{ hhh:

Cout<<” please enter number : “;

Cin>>search;

For( j=0;j<8;j++)

{
If(search == ar[j])

If(j!=0)

M++;

Temp=ar[j-1];

Ar[j-1]=ar[j];

Ar[j]=temp;

Ar2[j]++;

Temp=ar2[j-1];

Ar2[j-1]=ar2[j];

Ar2[j]=temp;

S=j;

Cout<<” index “<<s<<” new index “ <<s – 1<<endl;

Goto hhh;

Break;

///////////////////////////////////////////////////////////////index 0

Else

M++;

Ar2[j]++;

S=j;

Cout<<” index “<<s << “ please enter to try again \n”;

Goto hhh;

Break;

}
Else

N++;

/////////////////////////////////////////////////////////////

If(n == 8)

Cout<<”the number is not found\n”;

N=0;

Int temp2;

For( i=0;i<8;i++)

For( j=i+1;j<8;j++)

If(ar2[i]<=ar2[j])

Temp=ar2[i];

Ar2[i]=ar2[j];

Ar2[j]=temp;

Temp=ar[i];

Ar[i]=ar[j];

Ar[j]=temp;

}
}

Return 0;

You might also like