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.  
  9. if (count>=pitch) {
  10. count = 0;
  11. number = 1 - number;
  12. }else {
  13. count++;
  14. }
  15.  
  16. return number;
  17.  
  18. }
  19.  
  20. int main(void) {
  21. int n;
  22. int value;
  23. scanf("%d %d",&n,&pitch);
  24.  
  25. for (int i = 0; i < n; i++) {
  26. value = period();
  27. printf("%d",value);
  28. }
  29. printf("\n");
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 5320KB
stdin
20 3
stdout
00011110000111100001