只有10分 大佬看看
  • 板块P2084 进制转换
  • 楼主wshoca
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/3/12 21:35
  • 上次更新2023/10/23 21:42:53
查看原帖
只有10分 大佬看看
313067
wshoca楼主2023/3/12 21:35
#include<bits/stdc++.h>
#define M 1000
using namespace std;
int a[M];
int len = 0;

int main(){
	int k;
	string str;
	cin>>k>>str;
	len = str.length();
	string result;
	bool tag = true; 
	
	for (int i=0;i<len;i++){
		if (str[i]!='0'){
			if (tag!=true){
				result+='+';
			}
			//result+=to_string(a[i])+"*"+to_string(k)+"^"+to_string(len-i-1)+"+";
			result += str[i];
			result +='*';
			result += k + '0';
			result += '^';
			result += (len-i-1) + '0';
			tag = false;
			 }
}

	len = result.length();
	for (int i =0 ;i<len;i++){ 
		if (i==len-1&&result[i]=='+'){
			break;	
		}
		cout<<result[i];
	}

	 
}
2023/3/12 21:35
加载中...