wky_wsy @ 2024-07-18 16:34:33
虽然我并不是那么清楚我是否有救
不知道为啥0分的代码
#include <bits/stdc++.h>
using namespace std;
char z[10000000]="";
string m="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int r,n,l,i=0;
int main(){
scanf("%d%d",&n,&r);
l=n;
while(l){
z[i]=m[l%r-1];
l/=r;
}
int L=strlen(z);
for(int i=L-1;i>-1;i--){
printf("%c",z[i]);
}
return 0;
}
by zhangcnmua @ 2024-07-18 16:36:50
你说的是那道题?是编译错误么
by zhangcnmua @ 2024-07-18 16:38:40
@wky_wsy 建议用cin输入和cout输出
by zzy0618 @ 2024-07-18 16:40:47
@wky_wsy
l%r
不需要 -1
while
循环中你没有 i++
#include <bits/stdc++.h>
using namespace std;
char z[10000000]="";
string m="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int r,n,l,i=0;
int main(){
scanf("%d%d",&n,&r);
l=n;
while(l){
z[i]=m[l%r];
l/=r;++i;
}
int L=strlen(z);
for(int i=L-1;i>-1;i--){
printf("%c",z[i]);
}
return 0;
}
by wky_wsy @ 2024-07-18 16:43:55
@zzy0618
已AC,谢谢谢谢谢谢谢谢谢!
by zhangcnmua @ 2024-07-18 16:45:12
std::string dec_to_base(int N, int R) - {
const std::string digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
std::string result;
do {
} - while (N > 0);
return result; }
int main() {
}