the reference answer GPT ᴼ ᴾ ᴱ ᴺ ᴬ ᴵ < br / > here is a simple C language program, can realize the input 10 integers, and calculate the output of the number of positive, negative and zero:
#include
int main()
{
int arr[10];
int i, pos_num = 0, neg_num = 0, zero_num = 0;
printf("请输入10个整数:\n");
for(i = 0; i < 10; i++)
{
scanf("%d", &arr[i]);
if(arr[i] > 0)
pos_num++;
else if(arr[i] < 0)
neg_num++;
else
zero_num++;
}
printf("正数个数:%d\n", pos_num);
printf("负数个数:%d\n", neg_num);
printf("零的个数:%d\n", zero_num);
return 0;
}
The
program defines an integer array arr of length 10, which is used to store the input 10 integers. The program then iterates through the set of numbers through the for loop, judging the positivity of each element and counting the number of positive, negative, and zeros separately. Finally, the program outputs the statistics to the screen.
Note that in actual use, some basic checksum exception handling should be done on user input to prevent user input errors. For example, you can add some validity judgments to the input, such as determining whether the input is an integer.