救命,这哪错了呀,求大佬指点
查看原帖
救命,这哪错了呀,求大佬指点
44175
肥嘟嘟左卫门楼主2022/7/3 19:45
#include<bits/stdc++.h>
#include<cstdio> 
#include<cstdlib> 
using namespace std;
const long long maxx=0x3f3f3f3f3f3f3f3f;
const long long minn=0xc0c0c0c0c0c0c0c0;
const double pi = 4.0*atan(1.0);
#define int long long
#define f(i,n,m) for(long long i=n;i<=m;++i)
#define unf(i,n,m) for(long long i=n;i>=m;--i)
#define kong NULL
#define debug cout<<"sss"<<endl;


string u;
int n;
string s;
bool check(string str){
    int len = str.size(), k = 1, f = 0;
    while(k < len){if(isdigit(str[k]) && !isdigit(str[k - 1])) ++f; ++k;}
    if(f == 2) return 1; return 0;
}
vector<char>que;
void print_char(int x){
	if(x > 26){
		if(x % 26 == 0)
			print_char(x / 26 - 1), putchar('Z');
		else
			print_char(x / 26), putchar(x % 26 + 'A' - 1);
	}
	else putchar(x + 'A' - 1); 
}
void solve() {
cin>>n;
f(i,1,n){
    cin>>s;
    if(check(s)){
        int x=0,y=0;
        int po=1;
        while(s[po]>='0'&&s[po]<='9'){
            x=x*10+s[po]-'0';
            po++;
        }
        po++;
        int len=s.size();
        while(po<len){
            y=y*10+s[po]-'0';
            po++;
        }
        print_char(y);
        cout<<x<<endl;
    }
    else {
        u.clear();
        int len=s.size();
        int wei=0;
        f(i,0,len-1){
            if(s[i]>'9'||s[i]<'0')u+=s[i];
            else {wei=i;
            break;}
        }
        int chang=u.size();
        int fact=0;
        f(i,0,chang-1){
            fact=fact*26+(u[i]-'A'+1);
            
        }
        cout<<"R";
        f(i,wei,len-1)cout<<s[i];
        cout<<"C"<<fact<<endl;
        
    }
}


}
















signed main( )
{
ios::sync_with_stdio(false);
solve();
return 0;
}















2022/7/3 19:45
加载中...