Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
128651 罗迎甲 十进制转R进制 C++ Compile Error 0 MS 0 KB 447 2025-08-18 17:43:18

Tests(0/0):


Code:

#include<bits/stdc++.h> using namespace std; char num_to_char(int a) { if(a>=0&&a<=9){ return a+'0' } else{ return a+'A'-10; } } int main() { int i=0,temp=0;n,num=0,r,s=0; char str[100]={0} cin>>num; cin>>r; if(num==0){ cout<<0<<endl; return 0; } while(num){ temp=num%r str[s++]==num_to_char(temp) num/=r; } str[s]='\0' for(i=s-1;i>=0;i--){ cout<<str[i]; } cout<<endl; return 0; }


Run Info:

Main.cc: In function 'char num_to_char(int)':
Main.cc:7:2: error: expected ';' before '}' token
  }
  ^
Main.cc: In function 'int main()':
Main.cc:14:17: error: 'n' was not declared in this scope
  int i=0,temp=0;n,num=0,r,s=0;
                 ^
Main.cc:14:19: error: 'num' was not declared in this scope
  int i=0,temp=0;n,num=0,r,s=0;
                   ^
Main.cc:14:25: error: 'r' was not declared in this scope
  int i=0,temp=0;n,num=0,r,s=0;
                         ^
Main.cc:14:27: error: 's' was not declared in this scope
  int i=0,temp=0;n,num=0,r,s=0;
                           ^
Main.cc:16:2: error: expected ',' or ';' before 'cin'
  cin>>num;
  ^
Main.cc:28:13: warning: statement has no effect [-Wunused-value]
  for(i=s-1;i>=0;i--){
             ^
Main.cc:28:20: error: expected ';' before ')' token
  for(i=s-1;i>=0;i--){
                    ^