vex code pro v5#c++#机器人文件打不开
我在电脑上试了n次都打不开呢
建议自己写一个代码:
#include <iostream>
#include <cstring>
#include <stack>
using namespace std;
stack<char> s;
void turn (int t,int tmp)
{
while(t!=0)
{
if(t%tmp<=10)
s.push(t%tmp+'0');
else
s.push(t%tmp-10+'A');
t/=tmp;
}
}
int main()
{
int t,tmp;
while(cin>>t>>tmp)
{
turn(t,tmp);
while(!s.empty())
{
cout<<s.top();
s.pop();
}
cout<<endl;
}
return 0;
}
itoa函数
函数原型:****char*****itoa(``int
value,``char``*string,``int
radix);
例如:itoa(num, str, 2); num是一个int型的,是要转化的10进制数,str是转化结果,后面的值为目标进制。
PS:itoa并不是一个标准的函数,而是一个windows所特有的,如需要跨平台请使用sprintf
#include<cstdio>
#include<cstdlib> // 引入的头文件
int main()
{
int num = 10;
char str[100];
itoa(num, str, 2); //c++中一般用_itoa,用itoa也行,
printf("%s\n", str);
return 0;
}