
大数运算
han_hhh
这个作者很懒,什么都没留下…
展开
-
大数求和(string)
输入两串大数,求和这是原博客点击打开链接,下边自己打了一遍#include<iostream> #include<algorithm> using namespace std; string add(string s1,string s2){ string max=s1,min=s2; int i,j; if(s1.size()<s2.siz...转载 2018-04-24 21:41:34 · 928 阅读 · 3 评论 -
Children’s Queue HDU1297
There are many students in PHT School. One day, the headmaster whose name is PigHeader wanted all students stand in a line. He prescribed that girl can not be in single. In other words, either no girl...原创 2018-04-21 12:52:47 · 409 阅读 · 0 评论 -
大数相加(char)
原博客在这里点击打开链接,下边自己打了一遍#include<iostream> #include<algorithm> #include<cstring> using namespace std; char str1[500],str2[500],str3[500]; int len1,len2,i,j,k=0,g; int carry=0,temp; void...转载 2018-04-24 22:24:34 · 280 阅读 · 0 评论 -
HDU 1865 1string
You will be given a string which only contains ‘1’; You can merge two adjacent ‘1’ to be ‘2’, or leave the ‘1’ there. Surly, you may get many different results. For example, given 1111 , you can get 1...原创 2018-04-22 22:55:40 · 212 阅读 · 0 评论 -
大数相乘
思路: 经观察,已给字符串s1:1234,s2:12;乘积为s3 s3[4]=s1[3]*s2[1]; s3[3]=s1[2]*s2[1]+s1[3]*s2[0] 所以s3[i+j]=s1[i]*s2[j]; #include<stdio.h> #include<string.h> char str1[100],str2[100],str3[200]; int ...原创 2018-06-04 21:33:36 · 130 阅读 · 1 评论 -
基础练习 高精度加法
问题描述 输入两个整数a和b,输出这两个整数的和。a和b都不超过100位。 算法描述 由于a和b都比较大,所以不能直接使用语言中的标准数据类型来存储。对于这种问题,一般使用数组来处理。 定义一个数组A,A[0]用于存储a的个位,A[1]用于存储a的十位,依此类推。同样可以用一个数组B来存储b。 计算c = a + b的时候,首先将A[0]与B[0]相加,如果有进位产生,则把进...原创 2018-10-03 17:31:29 · 724 阅读 · 5 评论