Editorial
Read the input sequence into an array. Count the number of positive numbers. If it equals 0, then print “NO”. Otherwise, print the count of positive numbers and the numbers themselves.
Algorithm Implementation
Declare an array to store the sequence.
int m[101];
Read the input sequence into the array.
scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &m[i]);
In the variable cnt, count the number of positive numbers.
cnt = 0; for (i = 0; i < n; i++) if (m[i] > 0) cnt++;
If there are no positive numbers, then print “NO”.
if (cnt == 0) printf("NO\n"); else { // Print the count of positive numbers. printf("%d\n", cnt); // Print the positive numbers of the sequence. for (i = 0; i < n; i++) if (m[i] > 0) printf("%d ", m[i]); printf("\n"); }