日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

poj2562

發(fā)布時間:2025/7/14 65 豆豆
生活随笔 收集整理的這篇文章主要介紹了 poj2562 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

簡單題,類似高精度

View Code #include <iostream>
#include
<cstdio>
#include
<cstdlib>
#include
<cstring>
#include
<algorithm>
using namespace std;

#define maxn 12

char num1[maxn], num2[maxn];

int main()
{
//freopen("t.txt", "r", stdin);
while (1)
{
scanf(
"%s%s", num1, num2);
if (strcmp(num1, "0") == 0 && strcmp(num2, "0") == 0)
break;
reverse(num1, num1
+ strlen(num1));
reverse(num2, num2
+ strlen(num2));
int len, len2;
if (strlen(num1) > strlen(num2))
{
len
= strlen(num2);
len2
= strlen(num1);
for (int i = len; i < len2; i++)
num2[i]
= '0';
}
else
{
len
= strlen(num1);
len2
= strlen(num2);
for (int i = len; i < len2; i++)
num1[i]
= '0';
}
int temp = 0, jw = 0;
int ans = 0;
for (int i = 0; i < len2; i++)
{
int a = num1[i] - '0';
int b = num2[i] - '0';
temp
= a + b + jw;
jw
= temp / 10;
if (jw > 0)
ans
++;
}
if (ans == 0)
{
printf(
"No carry operation.\n");
}
else if (ans == 1)
{
printf(
"1 carry operation.\n");
}
else
{
printf(
"%d carry operations.\n", ans);
}
}
return 0;
}

總結(jié)

以上是生活随笔為你收集整理的poj2562的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。