我正在制作一个简单的计算器,其中列出了当有人输入两个整数时的所有内容。除了我似乎找不到那种演员的商,一切似乎都运作良好。
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#define SUM a + b
#define AVG (SUM) /(float) 2
#define SUBTRACTION a - b
#define MULTIPLICATION a * b
#define QUOTIENT
#define MODULUS a % b
void main()
{
int a, b;
printf("Enter two integers: ");
scanf("%d%d", &a, &b);
printf("\n\nThe Sum is %d\n", SUM);
printf("The Difference is %d\n", SUBTRACTION);
printf("The Multiplication is %d\n", MULTIPLICATION);
printf("The Quotient is %d\n", QUOTIENT);
printf("The Average is %0.2f\n", AVG);
printf("The Modulus is %d\n", MODULUS);
system("PAUSE");
}
答案 0 :(得分:1)
此行
#define QUOTIENT
应该是
#define QUOTIENT a / b
但应选中“除以零”