Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么我这代码只能过G++, C++过不了?

Posted by 15979203898 at 2018-04-15 17:10:13 on Problem 1503
#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int i, len, S;
	char Int[100], c, sum[102];
	memset(sum, '0', sizeof(sum));
	memset(Int, '\0', sizeof(Int));
	while (cin >> Int && strcmp(Int, "0"))
	{
		// 加法
		S = 0;
		len = strlen(Int);
		for (i = len - 1; i >= 0; i--)
		{
			S += Int[i] + sum[i + 102 - len];
			if (S > 9 + 96)
			{
				sum[i + 102 - len] = S - 10 - 48;
				S = 1;
			}
			else
			{
				sum[i + 102 - len] = S - 48;
				S = 0;
			}
		}

		// 计算sum进位
		i = i + 102 - len;
		while (S == 1)
		{
			sum[i]++;
			if (sum[i] > 48 + 9)
			{
				sum[i] -= 10;
				S = 1;
			}
			else
				S = 0;
			i--;
		}
		memset(Int, '\0', sizeof(Int));
	}

	// 输出
	for (i = 0; i < 102; i++)
	{
		if (sum[i] != '0')
			break;
	}

	if (i == 102)
		cout << 0 << endl;
	
	while (i < 102)
	{
		cout << sum[i];
		i++;
	}
	
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator