PROBLEM SOLVING
Ebook 541
Dev C++
source code :
Source Code :
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int i, j, max, temp;
int data[10];
cout<<"\t------Selection Sort------- "<<endl;
cout<<"Masukan banyak data ";
cin>>max;
for(i=1;i<=max;i++){
cout<<"Masukan data ke-"<<i<<" ; ";
cin>>data[i];
}
cout<<"Data Awal : ";
for(i=1;i<=max;i++){
cout<<data[i]<<" ";
}
for(i=1;i<=max;i++){
for(j=1;j<=max;j++){
if(data[i]>data[j]){
temp=data[i];
data[i]=data[j];
data[j]=temp;
}
}
}
return 0;
}
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int i, j, max, temp;
int data[10];
cout<<"\t------Selection Sort------- "<<endl;
cout<<"Masukan banyak data ";
cin>>max;
for(i=1;i<=max;i++){
cout<<"Masukan data ke-"<<i<<" ; ";
cin>>data[i];
}
cout<<"Data Awal : ";
for(i=1;i<=max;i++){
cout<<data[i]<<" ";
}
for(i=1;i<=max;i++){
for(j=1;j<=max;j++){
if(data[i]>data[j]){
temp=data[i];
data[i]=data[j];
data[j]=temp;
}
}
}
return 0;
}
outputnya :
Untuk Ebook Problem Solving silahkan kunjungi link dibawah ini :
538 : Ela Dwi Anggraini
419 : Agus Prasetyo
Tidak ada komentar:
Posting Komentar