Skip to content

Instantly share code, notes, and snippets.

@assem-ch
Created January 24, 2014 17:34
Show Gist options
  • Save assem-ch/8602128 to your computer and use it in GitHub Desktop.
Save assem-ch/8602128 to your computer and use it in GitHub Desktop.
#include <iostream>
//typedef struct element element;
using namespace std;
struct element {
char val;
element *next;
};
int main() {
element* tab[10];
for(int i = 0; i<10; i++) {
char c=0;
tab[i] = 0;
element *q=0;
cout<<"\nline"<<i<<"\n";
while(c!='x') {
cin>>c;
cout<<"*";
element *e = new element;
e->val = c;
e->next= 0; // NULL
if (q) q->next = e;
else tab[i] = e;
q=e;
}
}
for(int i = 0; i<10; i++) {
cout<<"\nline "<<i<<"\n";
for(element *e = tab[i]; e!=0; e=e->next)
{
cout<<"\t"<<e->val;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment