Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. void wstaw(char * cel, const char * zrodlo, char symbol) {
  2. unsigned int zrodlo_n = strlen(zrodlo);
  3. unsigned int offset = 0;
  4. unsigned int size = zrodlo_n + ceil(zrodlo_n / 3) + 1;
  5.  
  6. for (unsigned int i = 0; i < zrodlo_n; i++) {
  7. cel[i+offset] = zrodlo[i];
  8. if ((i+1) % 3 == 0) {
  9. offset++;
  10. cel[i+offset] = symbol;
  11. }
  12. }
  13.  
  14. cel[size-1] = '\0';
  15. for(int k=0;k<size;k++){
  16. cout<<cel[k]<<endl;}
  17. }
  18.  
  19. int main()
  20. {
  21. char t[]="Ala ma Kota";
  22. char z[20];
  23. wstaw(z,t,'x');
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement