Skip to main content

Mengurutkan string di C++

//*****************************************************************//
// Mengurutkan data array string menggunakan bubble sort //
// http://wirautama.net //
//*****************************************************************//
#include
#include
#include

void main()
{
clrscr();
//declare the variable and array
int n, test;
char data[10][100];
char tmp[100];
n = 10;

//input data
for(int i=0; i
{
cout<<"Data "<<(i+1)<<" : ";
cin>>data[i];
}

//sort data using bubble sort
for(int i=0; i
{
for(int j=i+1; j
{
test = strcmp(data[i], data[j]);
if(test > 0)
{
strcpy(tmp, data[i]);
strcpy(data[i], data[j]);
strcpy(data[j], tmp);
}
}
}
cout<<<"result>
for(int i=0; i
{
cout<<"Data "<<(i+1)<<" : "<<
}
getch();
}

Comments

Unknown said…
Gak bisa perbaiki scriptnya gan

Popular posts from this blog

Membuat website dengan CodeIgniter Part1

Langsung aja saya jabarkan kebutuhan yg akan di pakai nanti untuk membuat sebuah website d ari framework codeigniter... pertama.. ya tentu saja source dari codeigniter-nya... bisa pake yg terbaru atau 2.0 ++ disini kedua.. database -nya bisa menggunakan MySql yg udah di bundle ke dalam Xampp disini ketiga (optional) Editor teks.... pake notepad oke... pake netbeans oke juga... Langkah selanjutnya adalah install terlebih dahulu xampp-nya jika sudah ada xamppnya, lanjut ke langkah selanjutnya, lalu kemudian extract source Codeigniter di htdocs xampp. berikut susunan direktori Codeigniter root dir....         .../application                   .../cache                   .../config                   .../controllers      ...

A history of Einstein

Around 1886 Albert Einstein began his school career in Munich. As well as his violin lessons, which he had from age six to age thirteen, he also had religious education at home where he was taught Judaism. Two years later he entered the Luitpold Gymnasium and after this his religious education was given at school. He studied mathematics, in particular the calculus, beginning around 1891.  In 1894 Einstein's family moved to Milan but Einstein remained in Munich. In 1895 Einstein failed an examination that would have allowed him to study for a diploma as an electrical engineer at the Eidgenössische Technische Hochschule in Zurich. Einstein renounced German citizenship in 1896 and was to be stateless for a number of years. He did not even apply for Swiss citizenship until 1899, citizenship being granted in 1901.  Following the failing of the entrance exam to the ETH, Einstein attended secondary school at Aarau planning to use this route to enter the ETH in Zurich. While at Aarau he wr...