| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2633 人关注过本帖
标题:写入位置 0x0000000000000000 时发生访问冲突。怎么改过来啊,新手求助
只看楼主 加入收藏
我们要在一起
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2016-12-14
收藏
 问题点数:0 回复次数:2 
写入位置 0x0000000000000000 时发生访问冲突。怎么改过来啊,新手求助
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
using namespace std;
const int Max = 100;
class dazhengshu
{
public:
string addition(string &, string &);
void showjieguo();
private:
string outcome;
};
string dazhengshu::addition(string &str1, string &str2)
{
int x,y,mark = 0;
string str;
vector<int> num1(Max+10);
vector<int> num2(Max+10);
if(str1[0] == '-'&&str2[0] == '-')
{
mark = 1;
str1.erase(0,1);
str2.erase(0,1);
}
else if(str1[0] == '-'&&str2[0] != '-')
{
str1.erase(0,1);
outcome = addition(str2,str1);
return outcome;
}
else if(str1[0] != '-'&&str2[0] == '-')
{
str2.erase(0,1);
outcome =addition(str1,str2);
return outcome;
}
y = 0;
for(x = str1.size()-1; x >= 0; x--)
num1[y++] = str1[x]-'0';
y = 0;
for(x = str2.size()-1; x >= 0; x--)
num2[y++] = str2[x]-'0';
for(x = 0; x <= Max; x++)
{
num1[x] += num2[x];
if(num1[x]>=10)
{
num1[x] -= 10;
num1[x+1]++;
}
}
bool isBeginOutput = false;
for(x = Max; x >= 0;x--)
{
if(num1[x] != 0)
isBeginOutput = true;
if(isBeginOutput)
str += num1[x]+48;
}
if(!isBeginOutput)
str = "0";
if(mark)
str.insert(0,"-");
outcome = str;
return outcome;
}
void dazhengshu::showjieguo()
{
cout << outcome << endl;
}
int main()
{
string str1;
string str2;
dazhengshu a;
string store[10000];
char operation;
int m;
cin>>m;
for(int i=0;i<m;i++)
{
    (cin>>str1>>operation>>str2);
switch(operation)
{
case '+': store[i]=a.addition(str1,str2); ;break;
case '0':  exit(1);
}
}
for(int i=0;i<m;i++)
{
cout << store[i]<<endl;
}
system("pause");
return 0;
}

搜索更多相关主题的帖子: include private addition public 
2016-12-14 15:16
azzbcc
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:江西财经大学
等 级:贵宾
威 望:81
帖 子:3293
专家分:12919
注 册:2012-11-4
收藏
得分:0 
string store[10000];

数组开小点,我编译的时候栈空间炸了


[fly]存在即是合理[/fly]
2016-12-15 11:08
xzlxzlxzl
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:湖北
等 级:贵宾
威 望:125
帖 子:1091
专家分:5825
注 册:2014-5-3
收藏
得分:0 
我在vc里编译没发现问题,运行也正常,只是没看到输出,不知道题主要做什么!
2016-12-16 10:23
快速回复:写入位置 0x0000000000000000 时发生访问冲突。怎么改过来啊,新手求助 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018345 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved