0分求助大佬们,scanf那里有点问题细嗦

P4414 [COCI2006-2007#2] ABC

Yehoshua @ 2024-08-01 14:19:52

scanf那里我想用一个额外的字符去接收回车,但是我试了下无论有没有都是WA,这做法太蠢了嘛

#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;

int main()
{
    int n[4];
    char a,b,c,endl;
    for(int i=0;i<3;i++)  cin>>n[i];
    sort(n,n+3);
    scanf("%c%c%c%c",&endl,&a,&b,&c);
    cout<<n[a-65]<<" "<<n[b-65]<<" "<<n[c-65];
    return 0;
}

by meifan666 @ 2024-08-01 14:21:49

@Yehoshua 为何不用cin?


by meifan666 @ 2024-08-01 14:23:14

@Yehoshua 65是大写字母,改成97 就能AC 求关


by Yehoshua @ 2024-08-01 20:08:22

@meifan666 受教了,感谢大佬


|