liujunyua @ 2024-10-08 19:16:43
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int i;
char od;
char s[10001];
char ss[10001];
char ans[10001];
int main(){
scanf("%d",&i);
for(int j=1;j<=i;j++){
cin>>od;
if(od=='a'){
while(scanf("%s%s",s,ss)&&s!="c"&&s!="b"&&s!="a"){
int n,m;
sscanf(s,"%d",&n);
sscanf(ss,"%d",&m);
printf("%s+%s=%d\n",s,ss,n+m);
sprintf(ans,"%d",n+m);
printf("%d\n",strlen(s)+strlen(ss)+strlen(ans)+2);
memset(s,'\0',sizeof(s));
memset(ss,'\0',sizeof(ss));
memset(ans,'\0',sizeof(ans));
}
}
if(od=='b'){
while(scanf("%s%s",s,ss)&&s!="c"&&s!="b"&&s!="a"){
int n,m;
sscanf(s,"%d",&n);
sscanf(ss,"%d",&m);
printf("%s-%s=%d\n",s,ss,n-m);
sprintf(ans,"%d",n-m);
printf("%d\n",strlen(s)+strlen(ss)+strlen(ans)+2);
memset(s,'\0',sizeof(s));
memset(ss,'\0',sizeof(ss));
memset(ans,'\0',sizeof(ans));
}
}
if(od=='c'){
while(scanf("%s%s",s,ss)&&s!="c"&&s!="b"&&s!="a"){
int n,m;
sscanf(s,"%d",&n);
sscanf(ss,"%d",&m);
printf("%s*%s=%d\n",s,ss,n*m);
sprintf(ans,"%d",n*m);
printf("%d\n",strlen(s)+strlen(ss)+strlen(ans)+2);
memset(s,'\0',sizeof(s));
memset(ss,'\0',sizeof(ss));
memset(ans,'\0',sizeof(ans));
}
}
}
return 0;
}
蒟蒻半个小时未调出来,请大佬检查检查
by zhouyirana @ 2024-10-08 19:18:14
蒟蒻请放弃此题
by liujunyua @ 2024-10-08 19:19:18
彼此彼此(@黄名太佬)
by Lisuyang @ 2024-10-08 19:39:45
这么多memset,你说为什么T
by yj768988 @ 2024-10-08 19:47:11
@liujunyua 用string,这么多memset,你说为什么T
by liujunyua @ 2024-10-08 19:53:56
大佬,实力 @yj768988
by yj768988 @ 2024-10-08 19:55:34
@liujunyua 壶关,谢谢
by Wyl17370863080 @ 2024-10-09 13:12:27
#include <bits/stdc++.h>
using namespace std;
int T;
char ysf = ' ';
int main() {
cin >> T;
while(T--) {
string s;
int a, b;
cin >> s >> a;
if(s[0] == 'a' || s[0] == 'b' || s[0] == 'c') {
ysf = s[0];
cin >> b;
}else{
b = a;
a = stoi(s);
}
string t="";
if(ysf == 'a') {
t += to_string(a);
t += "+";
t += to_string(b);
t += "=";
t += to_string((a+b));
}
if(ysf == 'b') {
t += to_string(a);
t += "-";
t += to_string(b);
t += "=";
t += to_string((a-b));
}
if(ysf == 'c') {
t += to_string(a);
t += "*";
t += to_string(b);
t += "=";
t += to_string((a*b));
}
cout << t << '\n' << t.size() << '\n';
}
return 0;
}