字符串和数字的相互转化吧,两重分类:A长度,A[0]与B的大小关系
#include<cstdio>
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<cctype>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<string.h>
using namespace std;
#define N 10
int main()
{
string A,Q;
int B,R=0;
cin>>A>>B;
int temp=A[0]-'0';
if(A.length()>1)
{
if(temp>=B)
{
Q.push_back(temp/B+'0');}//注意string类到底怎样用
//else if(temp<B&&A.length()>1)
for(int i=1;i<A.length();i++)
{
R=temp%B;//此处的R只是先借来存储余数用于算temp
temp=R*10+A[i]-'0';
Q.push_back(temp/B+'0');
}R=temp%B;//此处R有实际意义
cout<<Q<<" "<<R;
}
else if(temp<B)
{
cout<<0<<" "<<temp;
}
else if(temp>B)
{
cout<<temp/B<<" "<<temp%B;
}
return 0;
}