Advertisement
nicuvlad76

Untitled

Nov 20th, 2020
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. char a[11][501][101];
  5. int v[11],n,m;
  6. void Cuvinte(char s[], int l)
  7. {
  8.     int c=0;
  9.     char *p;
  10.     p=strtok(s," ");
  11.     while(p)
  12.     {
  13.         c++;
  14.         strcpy(a[l][c],p);
  15.         p=strtok(0," ");
  16.     }
  17.     v[l]=c;
  18.     if(c>m)m=c;
  19. }
  20. void Citire()
  21. {
  22.     cin>>n;cin.get();
  23.     char s[1001];
  24.     for(int i=1;i<=n;i++)
  25.     {
  26.         cin.getline(s,1001);
  27.         Cuvinte(s,i);
  28.     }
  29.  
  30. }
  31. void Afisare()
  32. {
  33.    for(int j=1;j<=m;j++)
  34.     for(int i=1;i<=n;i++)
  35.     if(strlen(a[i][j])!=0) cout<<a[i][j]<<' ';
  36. }
  37. int main()
  38. {
  39.     Citire();
  40.     Afisare();
  41.     return 0;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement