大前端

前端学习之家-大前端

输入被除数和除数,求商。

**输入格式要求:"%d%d"  提示信息:"Enter two numbers:"
**输出格式要求:"cannot divide by zero.\n"(被0除)  "%d"(输出a/b)
程序运行示例如下:
Enter two numbers:8 3
2
程序运行示例如下:
Enter two numbers:6 3
2
程序运行示例如下:
Enter two numbers:9 0
cannot divide by zero.
#include<stdio.h>
int main()
{
    int m, n;
    printf("Enter two numbers:");
    scanf("%d%d", &m, &n);
    if(n != 0)
    {
        printf("%d", m / n);
    }
    else
    {
        printf("cannot divide by zero.\n");
    }
    return 0;
}

发表评论:

Copyright Your WebSite.Some Rights Reserved.