Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define N 1001
- #define M 10001
- using namespace std;
- ifstream fin("date.in");
- ofstream fout("date.out");
- char s[M], cuv[101][N],*p;
- short int a[101][N],b[101][N];
- int L,ct,n, S;
- void Pcta()
- {
- fin>>L;
- fin.get();
- fin.getline(s, M);
- p=strtok(s," ");
- strcpy(cuv[ct],"");
- while(p)
- {
- n=strlen(p);
- if(S+n+1<=L)
- {
- strcat(cuv[ct],p);
- strcat(cuv[ct]," ");
- S+=n+1;
- }
- else
- {
- ct++;
- strcat(cuv[ct],p);
- strcat(cuv[ct]," ");
- S=n+1;
- }
- p=strtok(0," ");
- }
- for(int i=0; i<=ct; i++)
- fout<<cuv[i]<<"\n";
- fout<<'\n';
- }
- void Pctb()
- {
- int ok=0;
- for(int i=0; i<=ct && !ok; i++)
- for(int j=0; cuv[i][j] && !ok; j++)
- if(cuv[i][j]==' ' && (cuv[i+1][j]==' '||cuv[i+1][j-1]==' '|| cuv[i+1][j+1]==' '))
- ok=1;
- if(ok==1) fout<<"DA\n" ;
- else fout<<"NU\n";
- }
- int main()
- {
- Pcta();
- Pctb();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement