题解 | #小乐乐查找数字#
小乐乐查找数字
https://www.nowcoder.com/practice/4c49a3a1559141f7a080a48c98cca4cb
#include <stdio.h> int main() { int n = 0; int x = 0; int arr[101] = {0}; while (1 == scanf("%d", &n)) { int count = 0; // 输入n个数据 for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } scanf("%d", &x); for (int i = 0; i < n; i++) { // 判断是否相等 if (arr[i] == x) { count++; } } printf("%d\n", count); } return 0; }