题解 | #小乐乐查找数字#
小乐乐查找数字
https://www.nowcoder.com/practice/4c49a3a1559141f7a080a48c98cca4cb
#include <stdio.h>//遍历数组,记录x的出现次数 #include <stdlib.h> int main() { int n,x; int count = 0; //记录x的出现次数 scanf("%d", &n); int* a = (int*)malloc(sizeof(int)*n); for(int i = 0; i < n; i++) { scanf("%d", &a[i]); } scanf("%d", &x); for(int i = 0; i < n; i++) { if(x == a[i]) count++; } printf("%d", count); return 0; }