#include <stdio.h> int count(int a[], int n) { int i, j, k = 0; for (i = 0; i < n; i++) { if (a[i] == 1) k++; else for (j = 2; j < a[i]; j++) if (a[i] % j == 0) { k++; break; } } return k; } int main() { int a[10], i; printf("输入10个数:"); for (i = 0; i < 10; i++) scanf("%d", &a[i]); printf("其中有%d个素数", 10 - count(a, 10)); return 0; }
by: 发表于:2018-05-25 16:03:00 顶(0) | 踩(0) 回复
??
回复评论