Kaskus

Tech

narutosupernovaAvatar border
TS
narutosupernova
[ask][c++] Program Freeze
#include <iostream>
using namespace std;

struct node{
int info;
node *next;
int jumlah;
}*awal = NULL, *akhir = NULL, *data;

void muncul()
{

cout<<"Linked list: ";
while(awal!=NULL)
{

cout<<awal->info;
awal=awal->next;
cout<<" ";
}
}

void tambah(int x, int y)
{
int temp;
data=new node;
data->info=x;
data->next=NULL;
if(awal==NULL)
{
awal=data;
}
for(int i=0;i<y;i++){
do{
if(data->info > data->info){
temp = data->info;
data->info = data->info;
data->info = temp;}
}while(i<y);
}
akhir->next=data;
akhir=data;
}

int main()
{
data =(struct node*)malloc(sizeof(struct node));
int jumlah,a;
cout<<"Jumlah Data: ";
cin>>jumlah;
cout<<endl;
for(int i =0 ;i<jumlah; i++){
cin>>a;
cout<<"Masukan: "<<a<<endl;
tambah(a,jumlah);}
muncul();
system("PAUSE");
return 0;
}

Ah program ini kan linked list yang ingin mensort angkanya jadi urut, nggak ada error tapi pas dijalanin koko bisa freeze yak.
&#91;ask&#93;&#91;c++&#93; Program Freeze
Ditunggu lama pun tetap melakukan hal yang sama nggak ada windows error
0
848
2
GuestAvatar border
Komentar yang asik ya
Urutan
Terbaru
Terlama
GuestAvatar border
Komentar yang asik ya
Komunitas Pilihan