[编程//在这段代码中,我只能输入一个值通过扫描F((函数虽然我使用了循环到5,但当我进入第一个值程序时,会自动结束什么错误,请回答??][1]代码:
#include<stdio.h>
#include<conio.h>
int main()
{
int arr[5];
int j=0;
if(j<5){
printf("entern");
scanf("%d",&arr[j]);
printf("well enter next");
int y;
y=arr[j];
if (y<5)
{ printf("value:%d",arr[j]);
}
j++;
}
return 0;
}
我认为您需要自己解决这个问题,但让我帮助您开始。
让我向你展示如何存储从键盘上提取的5个整数,你必须学习其余的。C是一门很难入门的语言,所以不要气馁,我也是一个初学者。
我还将使用一些我喜欢的代码格式。可能有更好的格式,但一定要考虑代码在屏幕上的外观。
实践.c
#include<stdio.h>
int main() {
int arr[5];
int j=0;
printf("Enter the first integer:");
while (j<5) {
scanf("%d",&arr[j]);
printf("Next:");
j++;
}
/* I'd then practice printing out the 5 integers.
* Then you can figure out how to stop the loop based on some logical condition.
*/
return 0;
}
编译使用:
gcc -Wall -o practice practice.c