Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio>
- #include <conio>
- #include <iostream>
- main(){
- int i, j, a, k, m;
- char nm[5][20], temp[40];
- cout<<"Inputkan 5 Nama\n";
- for (i=1;i<=5;i++)
- { cout<<"Input nama ke-"<<i<<" = ";gets(nm[i]);
- if (i>1)
- { for (j=1;j<=(i-1);j++)
- { a=(strcmp(nm[i], nm[j]));
- if (a<=0)
- { strcpy (temp, nm[i]);
- for (k=(i-1);k>=j;k--)
- { m=(k+1);
- strcpy (nm[m], nm[k]);
- }
- strcpy (nm[j], temp);
- }
- }
- }
- }
- cout<<"\nHasil pengurutannya adalah : \n";
- for (i=1;i<=5;i++)
- { cout<<"\n"<<nm[i];}
- getch();}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement