Advertisement
nicuvlad76

Untitled

Jan 19th, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define N 1001
  3. #define M 10001
  4. using namespace std;
  5.  
  6. ifstream fin("date.in");
  7. ofstream fout("date.out");
  8.  
  9. char s[M], cuv[101][N],*p;
  10. short int a[101][N],b[101][N];
  11. int L,ct,n, S;
  12. void Pcta()
  13. {
  14. fin>>L;
  15. fin.get();
  16. fin.getline(s, M);
  17. p=strtok(s," ");
  18. strcpy(cuv[ct],"");
  19. while(p)
  20. {
  21. n=strlen(p);
  22. if(S+n+1<=L)
  23. {
  24. strcat(cuv[ct],p);
  25. strcat(cuv[ct]," ");
  26. S+=n+1;
  27. }
  28. else
  29. {
  30. ct++;
  31. strcat(cuv[ct],p);
  32. strcat(cuv[ct]," ");
  33. S=n+1;
  34. }
  35. p=strtok(0," ");
  36. }
  37. for(int i=0; i<=ct; i++)
  38. fout<<cuv[i]<<"\n";
  39.  
  40. fout<<'\n';
  41.  
  42. }
  43. void Pctb()
  44. {
  45. int ok=0;
  46. for(int i=0; i<=ct && !ok; i++)
  47. for(int j=0; cuv[i][j] && !ok; j++)
  48. if(cuv[i][j]==' ' && (cuv[i+1][j]==' '||cuv[i+1][j-1]==' '|| cuv[i+1][j+1]==' '))
  49. ok=1;
  50. if(ok==1) fout<<"DA\n" ;
  51. else fout<<"NU\n";
  52. }
  53.  
  54. int main()
  55. {
  56. Pcta();
  57. Pctb();
  58. return 0;
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement