30分求助
查看原帖
30分求助
1050994
Lucid楼主2024/3/12 11:18
#include<bits/stdc++.h>

using namespace std;

int P;

string ten_to_P(int ten,int P) {
	
        string res;
	while(ten) {
		if(ten%P<10) {
	  		res+=to_string(ten%P);
		}
		else res+=ten%P+'A'-10;
		ten/=P;
	}
	reverse(res.begin(),res.end());
	return res;
}

int main() {
	
   cin>>P;
   
	for(int i=1;i<P;++i) {
		for(int j=1;j<=i;++j) {
			string s=ten_to_P(i*j,P);
			printf("%d*%d=%s ",i,j,s.c_str());
		}
		cout<<endl;
	}
	return 0;
}
2024/3/12 11:18
加载中...