请各位大佬帮忙看一下哪里出错了
查看原帖
请各位大佬帮忙看一下哪里出错了
1263343
BinaryFunction楼主2024/4/12 11:11
#include<bits/stdc++.h>
using namespace std;
int p,num[100]={0};
void transP(int n,int p){//将十进制数n转换为p进制数
	int i=0;
	while(n){
		num[i]=n%p;
		i++;
		n/=p;
	}
	for(i=i-1;i>=0;i--){
		if(num[i]>9){
			cout<<(char)(num[i]-10+'A');
		}
		else cout<<num[i];
	}
}
int main() {
	cin>>p;
	for(int i=1;i<p;i++){
		for(int j=1;j<=i;j++){
			if(i<=9&&j<=9){
				cout<<i<<"*"<<j<<"=";
				transP(i*j,p);
				cout<<" ";				
			}
			if(i>9||j>9){
				cout<<(char)(i-10+'A')<<"*"<<(char)(i-10+'A')<<"=";
				transP(i*j,p);
				cout<<" "; 
			}
		}
		cout<<endl;
	}
    return 0;
}
2024/4/12 11:11
加载中...