c - 查询 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;
}
'''
解决方案
推荐阅读
- java - 如何将 2 个数组从一个类传递到另一个类
- c# - IdentityServer4 基于角色的 ASP.NET Core 身份授权 = 拒绝访问
- c# - 如何修复 SonarQube“变量在至少一个执行路径上为空”?
- python - 在 Python 中,如何根据字符串列表从列表中删除项目?
- c# - 如何在 C# 中同时生成大量 HTTP HEAD 请求?
- python - 将连续的数字序列附加到列表中
- javascript - 如何使用 map 将数据从组件传递到 reactJs 上的另一个组件?
- android - 使用 Facebook SDK 手动记录应用安装事件
- git - 如何在不弄乱分支拉取请求关系的情况下挑选提交?
- python - from matplotlib.pyplot import plt ImportError: No module named 'matplotlib'