【特别篇】本小白目前做过最好的纯手打程序~

文章介绍了一个C++程序,可以计算给定基数B下的整数n的k次方,结果以5000位高精度显示。程序包括输入验证和乘法过程的实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

打开程序后输入B,n,k,即可得到B进制下n的k次方(5000位高精度),求各位大佬勿喷!!!

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
const int N=5000+1;
const int M=5000;
void slowsay(string x);
int a[N];
bool check[N];
int main()
{
	int B,k;
	int n;
	slowsay("2 <= B <= 36 , DON'T INPUT CASUALLY , OR THE SYSTEM WILL ERROR!!!\n\n");
	cin>>B>>n>>k;
	if(B<2||B>36){
		slowsay("\nWHAT ARE YOU DOING ?\n");
		return 0;
	}
	a[0]=1;
	check[0]=true;
	int x=0;
	int True=0;
	int la=M,checka=M;
	for(int i=1;i<=k;i++){
		while(check[True]){
			a[True]*=n;
			check[True]=true;
			True++;
		}
		for(int j=0;j<N;j++){
			if(a[j]>=B){
				x=a[j]/B;
				a[j]%=B;
				a[j+1]+=x;
			}
		}
		while(a[checka]==0){
			checka--;
		}
		for(int j=0;j<=checka;j++){
			check[j]=true;
		}
		checka=M;
		True=0;
	}
	while(a[la]==0){
		la--;
	}
	slowsay("\nIn base ");
	cout<<B;
	Sleep(20);
	slowsay(" , ");
	cout<<n;
	Sleep(20);
	slowsay(" ^ ");
	cout<<k;
	Sleep(20);
	slowsay(" is : \n\n");
	for(int i=la;i>=0;i--){
		if(a[i]<10){
			cout<<a[i];
			Sleep(1);
		}
		else{
			char l=a[i]-10+'A';
			cout<<l;
			Sleep(1);
		}
	}
	slowsay("\n\n");
	return 0;
}
void slowsay(string x){
	for(int i=0;i<x.size();i++){
		cout<<x[i];
		Sleep(20);
	}
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值