fork download
  1. #include <stdio.h>
  2.  
  3. int pitch;
  4. int period (void) {
  5. static int count = 0;
  6. static int number = 0;
  7.  
  8. if (count>=pitch) {
  9. count = 0;
  10. number = 1 - number;
  11. }else{
  12. count++;
  13. }
  14.  
  15. return number;
  16.  
  17. }
  18.  
  19. int main(void) {
  20. int n;
  21. int value;
  22. scanf("%d %d",&n,&pitch);
  23.  
  24. for (int i = 0; i < n; i++) {
  25. value = period();
  26. printf("%d",value);
  27. }
  28. printf("\n");
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5280KB
stdin
20 3
stdout
00011110000111100001