是否有更好的方法通过消除ifC语句中的重复条件来编写以下代码?
if
while (n < 0) { printf("Enter a positive integer: "); scanf("%d", &n); if (n < 0) { printf("Error: please enter a positive integer\n"); } }
谢谢.
c if-statement while-loop conditional-statements
c ×1
conditional-statements ×1
if-statement ×1
while-loop ×1