#include <stdio.h> int main() { int i, a[10], b[10]; for (i=0; i<10; i++) { printf("a[%d] = ", i); scanf("%d", &a[i]); } printf("Masiv b"); for (i=0; i<10; i++) { if (a[i]==a[i]) { printf("\nb[%d] = 1", i); } else (a[i]!=a[i]) { printf("\nb[%d] = 0", i); } } getchar(); return 0; } 

The task

Closed due to the fact that off-topic participants Kirill Malyshev , entithat , HolyBlackCat , 0xdb , aleksandr barakin December 28, '18 at 10:05 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Kirill Malyshev, entithat, 0xdb, aleksandr barakin
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • I wonder how you imagine when a[i]!=a[i] gives true ? ... - Harry
  • First, the purpose of the program is not clear, and secondly, it is not clear what exactly does not suit you? - Sonic Myst
  • Third, the task would be good to translate into Russian. - HolyBlackCat

1 answer 1

If I understand the condition correctly, the easiest way is something like this:

 int main() { int i,j, a[10], b[10] = {0}; for (i=0; i<10; i++) { printf("a[%d] = ", i); scanf("%d", &a[i]); } for (i=0; i<10; i++) { for (j=0; j<10; j++) if (i != j && a[i]==a[j]) { b[i] = 1; break; } } for (i=0; i<10; i++) printf("b[%d] = %d\n", i, b[i]); } 
  • Yes, all clearly thanks - Maxim Milutin