အခုတင္ျပေပးမွာကေတာ့ သုညကေန ၁၀၀ အတြင္ Random ေခါက္ထားတာေလးကို ၾကီးစဥ္ငယ္လိုက္စီတာနဲ႔ ငယ္စဥ္ၾကီးလိုက္စီတာေလးပဲျဖစ္ပါတယ္။
#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
int str[10],i,j,k,temp;
cout<<"The given String=";
for(k=0;k<10;k++)
{str[k]=rand()%100;
cout<<' '<<str[k];
}
cout<<endl;
cout<<"Decending order=";
for(i=0;i<10;i++)
{for(j=0;j<9-i;j++)
{if(str[j]>str[j+1])
{temp=str[j];
str[j]=str[j+1];
str[j+1]=temp;
}
}cout<<">"<<str[j];
}
getch();
}
ဒါေလးကို ရမ္းလိုက္မယ္ဆိုရင္ ရလာမွာကေတာ့ ေအာက္ကပံုအတိုင္း (ၾကီးစဥ္ငယ္လိုက္) ဆင္တူျဖစ္ပါ့မယ္။
#include<stdlib.h>
#include<conio.h>
void main()
{
int str[10],i,j,k,temp;
cout<<"The given String=";
for(k=0;k<10;k++)
{str[k]=rand()%100;
cout<<' '<<str[k];
}
cout<<endl;
cout<<"Decending order=";
for(i=0;i<10;i++)
{for(j=0;j<9-i;j++)
{if(str[j]<str[j+1])
{temp=str[j];
str[j]=str[j+1];
str[j+1]=temp;
}
}cout<<"<"<<str[j];
}
getch();
}
Comments :
Post a Comment