#include <stdio.h> int main(void) { int a[10] = {0, 1, 2, 3, 3, 5, 6, 7, 8, 3}; int b = 0;
printf("Please you input the number: "); scanf("%d", &b); int length = sizeof(a)/sizeof(int); for(size_t i = 0, j = 0; i != length; ++i){ if(b == a[i]){ ++j; printf("The number of %d times it appears in the array is %d\n", j, i+1); } } return 0; }
#include <stdio.h>
int main(void)
{
int a[10] = {0, 1, 2, 3, 3, 5, 6, 7, 8, 3};
int b = 0;
printf("Please you input the number: ");
scanf("%d", &b);
int length = sizeof(a)/sizeof(int);
for(size_t i = 0, j = 0; i != length; ++i){
if(b == a){
++j;
printf("The number of %d times it appears in the array is %d\n", j, i+1);
}
}
return 0;
}
#include <stdio.h> int main(void) { int a[10] = {0, 13, 2, 23, 3, 5, 6, 13, 3, 13}; int x = 0; size_t i, j, k; printf("Please you input the number: "); scanf("%d", &x); int length = sizeof(a)/sizeof(int); for(i = 0, j = 0; i != length; ++i){ if(x == a[i]){ j = i; continue; } } printf("The index of the last element that is the same as x is %d\n", j); return 0; }