修改文件结构。

This commit is contained in:
unlockable
2023-02-21 10:56:54 +08:00
parent a64cfdd9f3
commit 40182871f4
83 changed files with 0 additions and 0 deletions

21
POP/05/Exercise02.c Normal file
View File

@@ -0,0 +1,21 @@
#include <stdio.h>
int main() {
char operater;
int a = 0, b = 0, c = 0, d = 0;
double result;
scanf("%c %d %d %d %d", &operater, &a, &b, &c, &d);
if (b == 0 || d == 0 || (operater == '/' && c == 0)) {
printf("input error");
}
else {
switch (operater) {
case '+': result = (a/b)+(c/d); break;
case '-': result = (a/b)-(c/d); break;
case '*': result = (a/b)*(c/d); break;
case '/': result = (a/b)/(c/d); break;
}
printf("%lf", result);
}
return 0;
}