Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(void)
  6. {
  7. int n;
  8. char c;
  9. char s[1000000];
  10. scanf("%d\n",&n);
  11. c=getchar();
  12. int k=0;
  13. while(c!='EOF'){
  14. s[k]=c;
  15. c=getchar();
  16. k++;
  17. }
  18. int len=strlen(s);
  19. int N=0;
  20. for(int i=0;i<len;i++){
  21. if (s[i]==' ') N++;
  22. }
  23. int lish=n-len;
  24. int u;
  25. if(lish%N!=0) u=lish/N+1;
  26. else u=lish/N;
  27. for(int i=0;i<len;i++){
  28. if (s[i] != ' ')
  29. printf("%c",s[i]);
  30. else {
  31. for(int j=0;j<u;j++){
  32. putchar(' ');
  33. }
  34. if(N!=1){
  35. lish-=u;
  36. N--;
  37. if (N==0) {printf("NO"); return 0;}
  38. if (lish%N!=0)
  39. u=lish/N+1;
  40. else
  41. u=lish/N;
  42. }}
  43. }
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement