你看,我自学了C++(不完全,我还在拖延-_-).所以,现在我开始上大学,他们正在教C,他们让我们做了一个输入四个整数的程序,我们必须告诉它们中最大和最小的.简单,不是吗?
问题是,我已经对函数和数组有了很好的理解.是的,我可以在阵列中编程,没问题.但由于这是第一个实验室,我们还没有"学到"那个,所以我不能使用其中的任何一个,它就会非常简单.
这就是我在那里写的(某种程度上感觉不对).
#include<stdio.h>
int main(void)
{
int first, second, third, fourth;
printf("Enter four integers (separated by space): ");
scanf("%d %d %d %d", &first, &second, &third, &fourth);
if((first>second) && (first>third) && (first>fourth))
printf("\nFirst number is largest");
else if((second>first) && (second>third) && (second>fourth))
printf("\nSecond number is largest");
else if((third>second) && (third>first) && (third>fourth))
printf("\nThird number is largest");
else if((fourth>second) && (fourth>third) && (fourth>first))
printf("\nFourth number is largest");
if((first<second) && (first<third) && (first<fourth))
printf("\nFirst number is smallest");
else if((second<first) && (second<third) && …Run Code Online (Sandbox Code Playgroud) c ×1