fork(2) download
  1. #include <stdio.h>
  2. int main(void) {
  3.  
  4. int period(int* seq, int len)
  5. {
  6. char seq[10] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
  7. printf ("Please, write ten elements of this massive.");
  8. scanf ("%d", seq[0]);
  9. scanf ("%d", seq[1]);
  10. scanf ("%d", seq[2]);
  11. scanf ("%d", seq[3]);
  12. scanf ("%d", seq[4]);
  13. scanf ("%d", seq[5]);
  14. scanf ("%d", seq[6]);
  15. scanf ("%d", seq[7]);
  16. scanf ("%d", seq[8]);
  17. scanf ("%d", seq[9]);
  18. len = 10;
  19. int i, k;
  20. for (k = 1; k <= len / 2; k++)
  21. if (len % k == 0)
  22. {
  23. for (i = k; i < len; i++)
  24. if (seq[i] != seq[i%k])
  25. break;
  26. if (i == len)
  27. return k;
  28. }
  29. return 0;
  30. }
  31. printf ("The period of this massive is %d", period);
  32. }
  33.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'period':
prog.c:6:7: error: 'seq' redeclared as different kind of symbol
  char seq[10] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
       ^
prog.c:4:17: note: previous definition of 'seq' was here
 int period(int* seq, int len)
                 ^
prog.c:8:2: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
  scanf ("%d", seq[0]);
  ^
prog.c:9:2: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
  scanf ("%d", seq[1]);
  ^
prog.c:10:2: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
  scanf ("%d", seq[2]);
  ^
prog.c:11:2: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
  scanf ("%d", seq[3]);
  ^
prog.c:12:2: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
  scanf ("%d", seq[4]);
  ^
prog.c:13:2: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
  scanf ("%d", seq[5]);
  ^
prog.c:14:2: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
  scanf ("%d", seq[6]);
  ^
prog.c:15:2: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
  scanf ("%d", seq[7]);
  ^
prog.c:16:2: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
  scanf ("%d", seq[8]);
  ^
prog.c:17:2: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
  scanf ("%d", seq[9]);
  ^
prog.c: In function 'main':
prog.c:31:1: warning: format '%d' expects argument of type 'int', but argument 2 has type 'int (*)(int *, int)' [-Wformat=]
 printf ("The period of this massive is %d", period);
 ^
prog.c:32:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
stdout
Standard output is empty