void Calculate(int a)
{
int pa = a;
int count = ;
int b[] = {}; //将pa按位存储到数组b
while(pa > )
{
b[count++] = pa%;
pa = pa/;
}
bool flag = true; //是否有重复数
bool carryFlag = false; //是否产生进位 //从高位开始判断是否有重复数
int i,j,k;
count--;
for(i=count;i>;i--)
{
if(b[i] == b[i-])
{
flag = false;
b[i-]++; //有可能产生进位
if(b[i-]>)
carryFlag = true;
break;
}
} if(!flag) //如果存在重复位
{
int c = ;
//将低位重复数后面的数都变成0101....
for(j = i-;j>;j--)
{
b[j-] = c;
c = (c == ? :);
} //处理进位
if(carryFlag)
{
int carry = ;
for(j = i-;j<=count + ;j++)
{
b[j] = b[j] + carry;
if(b[j] >= )
{
carry = ;
b[j] = b[j] - ;
}
}
}
pa = ;
for(i = (count= ? count + :count);i >=;i--)
{
pa = pa * + b[i];
}
cout<<"the min no repeat number: "<<pa<<endl;
}
else
{
cout<<"the min no repeat number: "<<a<<endl;
return;
}
} 输入两个很大正数,输出它们的乘积
void Multiply(const char *a,const char *b)
{
assert(a!=NULL && b!=NULL);
int len_a = strlen(a);
int len_b = strlen(b);
int *c = new int[len_a+len_b];
memset(c,,sizeof(int) *(len_a+len_b));
for(int i=;i<len_a;i++)
{
for(int j=;j<len_b;j++)
{
c[i+j+] += (a[i]-'')*(b[j]-'');
}
}
for(int i=len_a+len_b-;i>;i--)
{
if(c[i]>=)
{
int carry = c[i]/;
c[i-] = c[i-] + carry;
c[i] = c[i] % ;
}
}
char *d = new char[len_a + len_b];
int i=;
while(c[i] == ) ++i;
int j;
for(j=;i<len_a+len_b;j++,i++)
{
d[j] = c[i] + '';
}
d[j] = '\0';
for(int i=;i<len_a+len_b;i++)
cout<<d[i];
cout<<endl;
}

最新文章

  1. [LeetCode] Bulls and Cows 公母牛游戏
  2. js④
  3. log4j 配置
  4. [BZOJ1061][Noi2008]志愿者招募
  5. Exception in thread &quot;AWT-EventQueue-0&quot; java.lang.IllegalThreadStateException
  6. gpfdist工具的初级使用
  7. Servlet&amp;JSP基础
  8. 【贪心】【POJ3154】墓地雕塑(Graveyard, NEERC 2006, LA 3708)需要稍稍加工的(先贪心,再确保能这样贪(可行性&amp;&amp;如果可行必定最优&amp;&amp;非证明最优性)的题)(K)
  9. 一套手写ajax加一般处理程序的增删查改
  10. .NET 4 并行(多核)编程系列之三 从Task的取消
  11. pig 的chararry不能用于比较的类型可以comparison operator
  12. ACM STUDY
  13. centos7 配置lamp 环境
  14. C++学习 —— 重新认识C++
  15. C#后台Post提交XML 及接收该XML的方法
  16. RxJS之BehaviorSubject
  17. AngularJS路由系列(5)-- UI-Router的路由约束、Resolve属性、路由附加数据、路由进入退出事件
  18. eclipse闪退解决
  19. 如何以编程方式打印到在 MFC 中的非默认打印机
  20. 爬虫框架之Scrapy——爬取某招聘信息网站

热门文章

  1. NATS连线协议具体解释
  2. strok函数用法【转】
  3. Generic Interfaces (C# Programming Guide)
  4. TensorFlow alexnet在华为Mate10上运行方法
  5. 写web项目注意事项
  6. Java Swing Action 动作
  7. 8.4 IP地址的划分及子网划分
  8. AcWing算法基础1.1
  9. Golang 入门 : goroutine(协程)
  10. Git 标记操作