zzxzzx_ @ 2024-11-12 19:27:52
#include<stdio.h>
int max(int a,int b){
if(a>b){
return a;
}
else return b;
}
int min(int a,int b){
if(a<b){
return a;
}
else return b;
}
int main(){
int a,b,c,e;
int o,p,q;
char d;
scanf("%d%d%d",&a,&b,&c);
o=min(min(a,b),c);//最小
//printf("%d\n",o);
q=max(max(a,b),c);//最大
//printf("%d\n",q);
e=a+b+c;
p=e-o-q;//中间
//printf("%d\n",p);
getchar();
for(int i=0;i<=2;i++){
scanf("%c",&d);
if(d=='A'){
printf("%d ",o);
}
else if(d=='B'){
printf("%d ",p);
}
else if(d=='C'){
printf("%d ",q);
}
}
return 0;
}
by __FL__ @ 2024-11-12 19:38:55
@zzxzzx_ 用cin/cout
过了
具体原因不太清楚,可能是getchar()
和scanf()
读入字符会出现奇怪的问题
by __FL__ @ 2024-11-12 19:45:11
见此
by xuxingcheng @ 2024-11-19 19:35:32
代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
int a1=min(min(a,b),c);
int c1=max(max(a,b),c);
int b1=(a+b+c)-(a1+c1);
string d;
cin>>d;
for(int i=0;i<d.size();i++){
if(d[i]=='A'){
cout<<a1<<" ";
}
if(d[i]=='B'){
cout<<b1<<" ";
}
if(d[i]=='C'){
cout<<c1<<" ";
}
}
return 0;
}
by ws778 @ 2024-12-07 18:47:29
@FL 遇到了这种情况,%c前面加个空格就对了,不知道为什么
by ws778 @ 2024-12-07 18:48:29
#include<stdio.h>
int main()
{
int a,b,c;
char g,h,j;
scanf("%d%d%d",&a,&b,&c);
getchar();
scanf("%c%c%c",&g,&h,&j);
int max=a>b?(a>c?a:c):(b>c?b:c);
int small=a<b?(a<c?a:c):(b<c?b:c);
int smax=a+b+c-max-small;
if(g=='A'&&h=='B'&&j=='C')
{
printf("%d %d %d",small,smax,max);
}
if(g=='A'&&h=='C'&&j=='B')
{
printf("%d %d %d",small,max,smax);
}
if(g=='B'&&h=='A'&&j=='C')
{
printf("%d %d %d",smax,small,max);
}
if(g=='B'&&h=='C'&&j=='A')
{
printf("%d %d %d",smax,max,small);
}
if(g=='C'&&h=='B'&&j=='A')
{
printf("%d %d %d",max,smax,small);
}
if(g=='C'&&h=='A'&&j=='B')
{
printf("%d %d %d",max,small,smax);
}
}
@FL
by __FL__ @ 2024-12-07 18:56:06
@ws778 scanf里空格可以屏蔽掉不可见字符