第五个点WA,求助
查看原帖
第五个点WA,求助
701144
YeZhetia楼主2022/5/13 23:14
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int read() {
  int x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * w;
}
inline void write(int x) {
  static int sta[35];
  int top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
}

int main(){
	ll x,y;
	char qwq;
	x=read(),y=read();
	scanf("%c",&qwq);
	if(qwq=='+') write(x+y);
	else if(qwq=='-') write(x-y);
	else if(qwq=='*' ) write(x*y);
	else if(qwq=='/'&&y!=0) write(x/y);
	else if(qwq=='/'&&y==0) cout<<"Divided by zero!";
	else cout<<"Invalid operator!";
	return 0;
}

2022/5/13 23:14
加载中...