如何在c ++ visual 6.00中运行此程序? [英] How do I run this program in c++ visual 6.00?

查看:70
本文介绍了如何在c ++ visual 6.00中运行此程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include< conio.h>

#include< iostream>

#include< math.h>

#include< stdlib .h>

#include< new>

使用命名空间std;

int main()

{

// clrscr();



int alternative = 0,criteria = 0,tentry = alternative * criteria;



double * criweight = new(nothrow)double [criteria];



double * positive = new(nothrow)double [tentry] ];



double * negative = new(nothrow)double [tentry];



double *得分= new(nothrow)double [tentry];



double * imp = new(nothrow)double [alternative];



cout<<输入替代号码:;

cin>>替代; //指定Alternative的数量。

cout<<输入标准数量:;

cin>>标准; //指定标准的数量。

cout<<\ n;



cout<<输入标准重量\ n;





//输入每个标准的权重。

for(int j = 0; j< criteria; j ++)

{

cout<<对应于标准#<< j + 1<<:;

cin>> criweight [j];

}



//显示用户输入的标准权重

cout<<\ n;

cout<<::你的标准权重是::\ n;

for(j = 0; j< criteria; j ++)

{

cout<< criweight [j]<<\t;

}



cout<<\ n;

system(pause);

//输入每个BVFS值的正数成员资格。

int index = 0;

cout<<\ n\ n;

cout<<输入正数会员值:;

cout<<\ n;

for(int i = 0; i< alternative; i ++)

{

for(int j = 0; j<标准; j ++)

{

cout<<对应于BVFS a<<< i + 1<<< j + 1<<:;

cin>>正面[指数];

指数++;

}



}

index = 0;

//以矩阵形式显示每个BVFS值的正成员资格

cout<<\ n :::你的正面会员价值是:::\ n;

for(i = 0; i< alternative; i ++)

{

for(int j = 0; j< criteria; j ++)

{

cout<< positive [index]<<\t;

index ++;

}

cout<<\ n ;

}

index = 0;

//系统(暂停);

//到输入每个BVFS值的Nagetive成员资格。

cout<<\ n\ n;

cout<<输入负面会员价值\ n ;

for(i = 0; i< alternative; i ++)

{

for(int j = 0; j< criteria ; j ++)

{

cout<<对应于<<< i + 1<<< j + 1<<:;

cin>>负[index];

index ++;

}

}

index = 0;

//以矩阵形式显示每个BVFS值的负成员资格

cout<<\ n;

cout<<:::你的负面会员价值是:::;

cout<<\ n;

for(i = 0; i< alternative; i ++)

{

for(int j = 0; j< criteria; j ++)

{

cout<< positive [index]<<\t;

index ++;

}

cout<<\ n ;

}

//使用SR-Score函数计算并显示每个BVFS值的得分。

index = 0;

系统(暂停);

cout<<\ n\ n;

cout<<::分数:每个与标准相对应的备选方案是:: \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n> \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n \\ n>
指数= 0;

\\ n
{

imp [i] = 0;

for(int j = 0; j< criteria; j ++)

{

得分[index] = 0;

得分[指数] = pow(正[指数],3) - (pow(criweight [j],3)*(pow(负[指数],3)))+正数[指数] ] - (criweight [j] * negative [index]);

cout<< score [index]<<\t\t;

imp [i] + =得分[指数]; //计算每个替代品的重要性。

index ++;

}

cout<<\ n;

系统(暂停);

}

系统(暂停);

//显示每个替代品的重要性。

cout<<\ n \ n;

for(i = 0; i< alternative; i ++)

{

cout<<替代#的重要性<< i + 1<<=<< imp [i]<<\ n;

}

系统(暂停);

//计算并显示最佳替代品。

cout< <\ n\ n;

double best = 0,large = imp [0];

for(i = 0; i< alternative; i ++)

{

if(large< = imp [i])

{large = imp [i];

best = i;

}

}

cout<<节拍替代品是#<< best + 1<<<<<<<<<<<<<<<" \ n \ n;

system(暂停);



//由上面定义的数组占用的延迟内存。

delete []正;

delete []否定;

删除[]得分;

删除[] criweight;

删除[] imp;

返回0;

getche();



}









0042E9B0 ???

0042E9B1 ???

0042E9B2 ???

0042E9B3 ????

0042E9B4 ???

0042E9B5 ???

=> 0042E9B6 ???问题在这里

0042E9B7 ???

0042E9B8 ???

0042E9B9 ???

0042E9BA ?? ?

0042E9BB ???

0042E9BC ???

0042E9BD ???







问题#1)))))。exe 0xC0000005访问违规中未处理的异常

probleum#2)))) )它给出了正确的结果,最后只有8个结果出来之后来的是ans错了





plz cheack这些在输入中有价值

优先9

然后3

然后1 1 1

然后给所有条目最后给出0.2





如果你在任何时候得到结果零(0)所以答案是正确否则错误

解决方案

否。我没有运行你的代码并为你尝试:相反,在调试器中运行它,并尝试解决发生的事情。



设置一个断点函数的第一行,并通过调试器运行代码。然后查看您的代码,并查看您的数据并找出手动应该发生的事情。然后单步执行每一行检查您预期发生的情况正是如此。如果不是,那就是当你遇到问题时,你可以回溯(或者再次运行并仔细观察)以找出原因。


对不起,但我们不能为你做到这一点 - 时间让你学习一门新的(非常非常有用的)技能:调试!


#include<conio.h>
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<new>
using namespace std;
int main()
{
//clrscr();

int alternative=0,criteria=0,tentry=alternative*criteria;

double *criweight= new (nothrow) double[criteria];

double *positive = new (nothrow) double[tentry];

double *negative = new (nothrow) double[tentry];

double *score = new (nothrow) double[tentry];

double *imp = new (nothrow) double[alternative];

cout<<"Enter Number of Allternative: ";
cin >>alternative; // specifi the number of Alternative.
cout<<"Enter Number of Criteria: ";
cin>>criteria; // specifi the number of Criteria.
cout<<"\n";

cout<<"Enter Weightage of Criteria \n";


// To Enter weightage of each criteria.
for (int j = 0; j < criteria; j++)
{
cout<<"Corresponding to Criteria # "<<j+1<<": ";
cin>>criweight[j];
}

// To display the weightage of criteria enter by user
cout<<"\n";
cout<<" : : Your criteria Weightage are : : \n ";
for (j = 0; j < criteria; j++)
{
cout <<criweight[j] <<"\t";
}

cout<<"\n";
system("pause");
// To Enter Positive membership of each BVFS value.
int index=0;
cout<<"\n\n";
cout<<"Enter Positive membership values: ";
cout<<"\n";
for (int i = 0; i < alternative; i++)
{
for (int j = 0; j < criteria; j++)
{
cout<<" Corresponding to BVFS a"<<i+1<<j+1<<" : ";
cin>>positive[index];
index++;
}

}
index=0;
// Display Positive membership of each BVFS value in Matrix form
cout<<"\n: : : Your Positive membership values are : : :\n";
for (i = 0; i < alternative; i++)
{
for (int j = 0; j < criteria; j++)
{
cout << positive[index] <<"\t";
index++;
}
cout<<"\n";
}
index=0;
//system("pause");
// To Enter Nagetive membership of each BVFS value.
cout<<"\n\n";
cout<<"Enter Negative membership values \n";
for (i = 0; i < alternative; i++)
{
for (int j = 0; j < criteria; j++)
{
cout<<" Corresponding to a"<<i+1<<j+1<<" : ";
cin>>negative[index];
index++;
}
}
index=0;
// Display Negative membership of each BVFS value in Matrix form
cout<<"\n";
cout<<": : : Your Negative membership values are : : :";
cout<<"\n";
for (i = 0; i < alternative; i++)
{
for (int j = 0; j < criteria; j++)
{
cout << positive[index] <<"\t";
index++;
}
cout<<"\n";
}
// Calculate and display Score of each BVFS value by using SR- Score function.
index=0;
system("pause");
cout<<"\n\n";
cout<<": : Score of each Alternative Corresponding to Criteria is : :\n";
index=0;
for (i = 0; i < alternative; i++)
{
imp[i]=0;
for (int j = 0; j < criteria; j++)
{
score[index]=0;
score[index]=pow(positive[index],3)-(pow(criweight[j],3)*(pow(negative[index],3)))+positive[index]-(criweight[j]*negative[index]);
cout<<score[index]<<"\t\t";
imp[i]+=score[index]; // Calculate Importance of each Alternative.
index++;
}
cout<<"\n";
system("pause");
}
system("pause");
// Display Importance of each Alternative.
cout<<"\n\n";
for (i = 0; i < alternative; i++)
{
cout<<"Importance of Alternative # "<<i+1<<" = "<<imp[i]<<"\n";
}
system("pause");
// Calculate and display Best Alternative.
cout<<"\n\n";
double best=0,large=imp[0];
for (i = 0; i < alternative; i++)
{
if(large<=imp[i])
{ large=imp[i];
best = i;
}
}
cout<<"The beat Alternative is # "<<best+1<<" whose's Importance is "<<large<<"\n\n";
system("pause");

// Delate memory occupied by array define above.
delete[] positive;
delete[] negative;
delete[] score;
delete[] criweight;
delete[] imp;
return 0;
getche();

}




0042E9B0 ???
0042E9B1 ???
0042E9B2 ???
0042E9B3 ???
0042E9B4 ???
0042E9B5 ???
=>0042E9B6 ??? probleum is here
0042E9B7 ???
0042E9B8 ???
0042E9B9 ???
0042E9BA ???
0042E9BB ???
0042E9BC ???
0042E9BD ???



probleum # 1))))) Unhandled exception in .exe 0xC0000005 access violation
probleum # 2))))) it give correct outcome only upto 8 outcome after that out come ans is wrong


plz cheack these valued in input
first 9
then 3
then 1 1 1
then give 0.2 for all entry upto last


if u get outcome zero( 0 ) at all point so the answer is correct otherwise wrong

解决方案

No. I'm not running your code and trying it for you: instead, run it in the debugger, and try to work out what is happening.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!


这篇关于如何在c ++ visual 6.00中运行此程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆