在线编译器 C

#include <stdio.h> int main() { int A[10]; int pos[10]; int neg[10]; int pos_count = 0; int neg_count = 0; for (int i = 0; i < 10; i++) { scanf("%d", &A[i]); } for (int i = 0; i < 10; i++) { if (A[i] > 0) { pos[pos_count] = A[i]; pos_count++; } else if (A[i] < 0) { neg[neg_count] = A[i]; neg_count++; } } for (int i = 0; i < neg_count; i++) { printf("%d ", neg[i]); } return 0; }
This code reads 10 integers into array A, then separates positive numbers into array pos and negative numbers into array neg. Finally, it prints only the negative numbers.

- The code does not print the positive numbers. After printing negatives, you need to add a loop to print the positive numbers stored in the pos array.
- The output format might need a space or newline between the two groups. Consider how you want the positive numbers to appear after the negatives.