Advertisement
alexon5519

42-programare

May 13th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include<fstream>
  3. #include<string.h>
  4. #include<stdio.h>
  5. #include<stdlib.h>
  6.  
  7. using namespace std;
  8.  
  9. int main(){
  10. ifstream f1("atestat.in");
  11. ofstream f2("atestat.out");
  12. char n[100];
  13. int i,l=0;
  14. f1.getline(n,100);
  15. for(i=1;i<strlen(n);i++){
  16. if(n[i-1] != n[i] && l >= 2){
  17. f2<<endl;
  18. l=0;
  19. }
  20. if(n[i-1] == n[i] && ( n[i-1] >= 'a' && n[i-1] <= 'z' && n[i] >= 'a' && n[i] <= 'z' )){
  21. l++;
  22. if(l <= 2)
  23. f2<<n[i-1];
  24. strcpy(n+i-1,n+i);
  25. i--;
  26. }
  27. }
  28. f2<<n;
  29. f1.close();
  30. f2.close();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement