设计一个程序,将10进制转换为12进制

来源:百度知道 编辑:UC知道 时间:2024/06/08 10:21:43
用VB编写程序,我要代码呀。

VB不会,给个C的给你参考下 改成VB格式就Ok了
int test(int xx){
int i=xx%12; //取余数
if(xx==0)return; //返回
xx=xx/12; //
test(xx); //递归调用
printf("%d",i); //输出i的值
}

#include"iostream.h"
void f(float n){
int m = n;char c;int v = 5;
int i = 0;char c1;int t = 0;
float e = n - (int)n;
int arr[20];
while(m>=12){
int a = m%12;
if(a==10){
t = 1;
++i;
c = 'a';
arr[i] = i;
}else if(a == 11){
t = 1;
++i;
c1 = 'b';
arr[i] = i+1;
}else{
++i;
arr[i] = a;
}
m = m/12;
}
arr[i+1] = m;
for(int j=i+1;j>0;j--){
if(t ==1 && j == arr[j]){
cout<<c;
}else if(t == 1 && j+1 == arr[j]){
cout<<c1;
}else{
cout<<arr[j];
}
}
if(e>0){
cout<<".";