UVA 10106 (暑假-高精度-A - Product)
来源:互联网 发布:js base64转换为文件 编辑:程序博客网 时间:2024/05/29 09:21
#include <stdio.h>#include <string.h>const int Max = 1000;int main() {char str_1[Max], str_2[Max];memset(str_1, 0, 1000);memset(str_2, 0, 1000);while (gets(str_1)) {gets(str_2);int count = 0;ints[2*Max] = {0};int arr_1[Max] = {0}, arr_2[Max] = {0};//输入数据int len_1 = strlen(str_1);int len_2 = strlen(str_2);for (int i = 0; i < len_1; i++)arr_1[i] = str_1[len_1 - i - 1] - '0';for (int j = 0; j < len_2; j++)arr_2[j] = str_2[len_2 - j - 1] - '0'; int i, j;for (i = 0; i < Max; i++) //计算for (j = 0; j < Max; j++) {s[i+j]= s[i+j] + arr_1[i] * arr_2[j];if (s[i+j] >= 10) {s[i+j+1] += s[i+j] / 10;s[i+j] = s[i+j] % 10; }}//输出数据if (str_1[0] == '0' && len_1 == 1 || str_2[0] == '0' && len_2 == 1)printf("%d", s[i]);else {for (i = 2 * Max - 1; i >= 0 ; i--)if (s[i] != 0)break;for (; i >= 0; i--)printf("%d", s[i]);}memset(str_1, 0, 1000);memset(str_2, 0, 1000);printf("\n");}return 0;}/*for (i = 0; i < 2*Max; i++)s_1[i] = s[Max*2-i-1], printf("%d", s[i]);printf("\n");for (i = 0; i < 2*Max; i++)printf("%d",s_1[i] );printf("\n");*//*for (i = 0; i< 2*Max; i++)if (s_1[i] != 0)break;for (; i < 2*Max; i++)printf("%d",s_1[i] );printf("\n");*//*if (count) printf("%d", s[i]);else if (!count && s[i] == 0)count = true;*///检查输入的数据是否正确保存/*for (int i = 0; i < len_1; i++)printf("%d", arr_1[i]);printf("\n");for (int j = 0; j < len_2; j++)printf("%d", arr_2[j]);printf("\n");puts(str_2);*/
0 0
- UVA 10106 (暑假-高精度-A - Product)
- UVa 10106 Product (高精度)
- Product - UVa 10106 高精度
- UVA 10106 Product 高精度乘法
- UVa 10106 - Product 高精度乘法-
- Uva 10106 Product (高精度相乘)
- UVA 10106 Product 高精度运算
- UVA 10106 Product (高精度乘法)
- uva 10106 Product(高精度乘法)
- UVA 10106 Product 简单高精度乘法
- uva 10106 Product(高精度大数乘法)
- (高精度运算4.7.21)UVA 10106Product(大数乘法)
- uva 424 Integer Inquiry(高精度加法模板) uva 10106 Product(高精度乘法模板)
- 高精度-10106 product
- UVA 10494 (暑假-高精度 -D - If We Were a Child Again)
- UVA 748 (暑假-高精度-C-Exponentiation)
- UVA 465 (暑假-高精度 -B - Overflow)
- UVa 10106 Product
- sqlplus登录问题
- BOJ 389 Bricks
- 减少.NET应用程序内存占用的一则实践
- 黑马程序员_进军黑马的第一篇博文
- NPAPI——实现非IE浏览器的类似ActiveX的本地程序(插件)调用
- UVA 10106 (暑假-高精度-A - Product)
- J2SE基础:4.面向对象的特性一
- 在Ubuntu操作系统上安装mono和jexus搭建.NET的运行环境
- Hibernate注解插入有空字段实体映射类:实体类有空字段插入数据库时空属性插入为默认值
- ZOJ-1111
- DevExpress传统界面设计:ToolBar和工具条停靠控件、和popupMenu弹出菜单
- iOS 根据文本内容为TextView动态定义高度
- 《iOS 7 Programming Pushing the Limits》系列:你可能不知道的ObjC技
- 跟我学设计设计模式视频教程(一)-设计模式概述&单例模式