Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
1075 曾浩森 进制转换2 C++ Compile Error 0 MS 0 KB 708 2023-07-01 15:08:13

Tests(0/0):


Code:

#include<iostream> using namespace std; int n; string x(int a,int b){ int x,i; string s; char c; s=""; while(a!=0){ x=a%b; if(x>=0&&x<=9){ c=x+48; } else c=65+x-10; s=c+s; a=a/b; } return s; int k(string s,int x){ string s; int a=0,b=1; for(int i=s.size()-1;i>=0;i--){ if(s[i]>='A'&&s[i]<='F') a=(s[i]-'A'+10)*b+a; else a=(s[i]-48)*b+a; b=b*x; } return a; } } int main(){ int n,m,b; string a; cin>>n>>m; cin>>a; b=k(a,n); cout<<x(b,m); }


Run Info:

Main.cc: In function 'std::string x(int, int)':
Main.cc:22:22: error: a function-definition is not allowed here before '{' token
 int k(string s,int x){
                      ^
Main.cc:5:11: warning: unused variable 'i' [-Wunused-variable]
     int x,i;
           ^
Main.cc:47:5: error: expected '}' at end of input
     }
     ^