非负大整数加法---网易校招附加题
来源:互联网 发布:sql查询命令 编辑:程序博客网 时间:2024/06/06 01:14
网易2017校招内推附加题简单实现,大整数减法实现待续。。。:原题为实现一个大整数加减法的类。
string TwoBigInt(string str_bigNumber1,string str_bigNumber2){int length1 = str_bigNumber1.size();int length2 = str_bigNumber2.size();if(length1 > length2){str_bigNumber1.insert(0,length1 - length2,'0');}else if(length2 - length1){str_bigNumber1.insert(0,length2 - length1,'0');}string s = "";int cnt = 0;int i,j;for(i = length1 - 1; i >= 0; j--,i--){int sum = cnt + (bigNumber1[i] - '0') + (bigNumber2[j] - '0');int current = sum % 10;s = (current + '0') + s;cnt = sum / 10;}if(cnt == 1)s.insert(0,'1');return s;}
1 0
- 非负大整数加法---网易校招附加题
- 网易校招笔试题
- 滴滴附加题(2018校招)
- 网易校招笔试题 炮台攻击
- 网易校招笔试题 炮台攻击
- 网易校招编程题 计算糖果
- 网易校招编程题 翻转数字
- 2018网易游戏校招笔试题
- 网易校招编程题之藏宝图
- 网易2018校招编程题集合
- 2017 网易校招编程题
- 网易2018校招编程题
- 网易2018校招编程题
- 【网易】2018校招笔试题
- 网易2018校招编程题3
- 网易2018校招编程题5
- 网易2018校招编程题集合
- 网易校招面试
- <p>标签使用
- Servlet-生命周期
- platform驱动学习
- HDU 4597 Play Game (DP 记忆话搜索)
- Struts 2中的constant详解
- 非负大整数加法---网易校招附加题
- 数据结构
- Swift与OC的对比
- mac item2配色、大小写敏感、vim配色、ls配色、常用快捷键
- Ubuntu历史版本下载地址
- Logging separation
- Swing是一把刀(转载)
- iOS 从Objective-C到Swift
- 关联Tomcat服务器