Cod sursa(job #2550110)
Utilizator | Data | 18 februarie 2020 14:23:36 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.5 kb |
#include <iostream>
#include <cstring>
using namespace std;
char a[256];
int L,s;
int main()
{
cin>>L;
cin.get();
cin.getline(a,256);
char *p=strtok(a," ");
while (p)
{
if(s+strlen(p)<L)
{
s=s+strlen(p);
cout<<p<<" ";
s++;
}
else if (s+strlen(p)>=L)
{
cout<<endl<<p<<" ";
s=0;
s=strlen(p)+1;
}
p=strtok(NULL," ");
}
return 0;
}