首页 > 解决方案 > 查询 C 语言

问题描述

如果我们将 \n 放在 Scanf 行的 %d 之后,为什么程序需要 2 次使用输入????

'''
#include<stdio.h>

int main(){
int i=1;
int n;
printf("Enter the value of n\n");
scanf("%d\n",&n);
do{
    printf("The %d natural number is: %d\n",i, i);
    i++;
}
while(i<=n);
return 0;
}
'''

标签: cxcodeperformancevisual-studio-codescanf

解决方案


推荐阅读