Created
January 24, 2014 17:34
-
-
Save assem-ch/8602128 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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