Advertisement
Anna3O0

Caractere Fisa 9

Nov 22nd, 2020 (edited)
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. ifstream f1("cuvinte.in");
  8. ofstream f2("cuvinte.out");
  9.  
  10. void fisier(char a[50][50])
  11. {
  12.     char aux[50];
  13.     int n=0,i,j;
  14.     while(f1>>a[n])
  15.         n++;
  16.     for(i=0;i<n-1;i++)
  17.         for(j=i;j<n;j++)
  18.             if(strcmp(a[i],a[j])>0)
  19.             {
  20.                 strcpy(aux,a[i]);
  21.                 strcpy(a[i],a[j]);
  22.                 strcpy(a[j],aux);
  23.             }
  24.     for(i=0;i<n;i++)
  25.         f2<<a[i]<<endl;
  26. }
  27.  
  28. void cuvMij(char s[256])
  29. {
  30.     int i=0;
  31.     cin.get(s,255);
  32.     cout<<s<<endl;
  33.     while(i<strlen(s))
  34.     {
  35.         strcpy(s,s+1);
  36.         s[strlen(s)-1]=NULL;
  37.         cout<<s<<endl;
  38.     }
  39.  
  40. }
  41.  
  42. int main()
  43. {
  44.     //char a[50][50]; in caz ca vrei sa rulezi subprogramul fisier
  45.     //fisier(a);
  46.     char s[256];
  47.     cuvMij(s);
  48.  
  49.     return 0;
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement