Advertisement
edutedu

se citeste un text prin care cuvintele sunt separate prin 1s

Apr 2nd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char a[100];
  8. int i,n;
  9. cout<<"Introduceti sirul:";
  10. cin.get(a, 100);
  11. n=strlen(a);
  12. for(i=0; i<=n; i++)
  13. {
  14. if(a[i+1]==' ' && a[i]==' ')
  15. {
  16. strcpy(a+i, a+i+1);
  17. i--;
  18. }
  19. }
  20. cout<<a;
  21.  
  22.  
  23.  
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement