Kaskus

Tech

narutosupernovaAvatar border
TS
narutosupernova
[ask][c++] Linked list
Code:
#include<iostream>
using namespace std;

struct node
{
int data;
struct node *link;
};



int main()
{
srand(time(NULL));
int opt, counter = 0,input;
struct node *n;
struct node *p = NULL;
struct node *status = NULL;
cin>>input;
for(int i=0;i<input;i++){

n= (struct node*)malloc(sizeof(struct node));
n->data=rand()+1;
n->link=p;
p=n;
cout<<p->data<<" ";
}
cout<<p->data

cout << endl;

system("pause");
return 0;
}


anu gimana cara linked list ya bisa dicout soalnya cuma keluara yang terakhir doang
0
526
2
GuestAvatar border
Komentar yang asik ya
Urutan
Terbaru
Terlama
GuestAvatar border
Komentar yang asik ya
Komunitas Pilihan