比较两个输入中较小的那个值

#include stdio.hint imin(int, int);int main(void){int evil1, evil2;printf(Enter a pair of integers (q to quit):\\n);

编程学习网为您整理以下代码实例,主要实现:比较两个输入中较小的那个值,希望可以帮到各位朋友。

#include <stdio.h>
int imin(int, int);

int main(voID)
{
    int evil1, evil2;

    printf("Enter a pair of integers (q to quit):\n");
    while (scanf("%d %d", &evil1, &evil2) == 2)
    {
        printf("The lesser of %d and %d is %d.\n", evil1, evil2, imin(evil1,evil2));
        printf("Enter a pair of integers (q to quit):\n");
    }
    printf("Bye.\n");

    return 0;
}

int imin(int n,int m)
{
    int min;

    if (n < m)
        min = n;
    else
        min = m;

    return min;
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐