Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
#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
Posted
Comments
Sergey Alexandrovich Kryukov 28-Feb-15 0:35am    
Did you notice that your code starts with
#include
#include

Please first make it readable. Escape HTML and sandwich is in "pre" tags.

What do you mean by "how do I run"? Do you have compiled code to run?

—SA
Member 11486551 2-Mar-15 13:20pm    
there are problems in run this
1) its do not give correct out put at this interval


// 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++;
}


2nd problem is that it terminat without run completely and show break point at

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


i run this program but the there are problem in executing
Member 11486551 2-Mar-15 13:27pm    
i run this By using iostream.h, conio.h, math.h, process.h,

1 solution

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!
 
Share this answer
 
Comments
Member 11486551 2-Mar-15 13:22pm    
there are problems in run this
1) its do not give correct out put at this interval


// 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++;
}


2nd problem is that it terminat without run completely and show break point at

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


i run this program but the there are problem in executing
i full agree that these coding are correct there is no problem in coding
OriginalGriff 2-Mar-15 14:04pm    
"i full agree that these coding are correct there is no problem in coding"
I don't.
If it's giving the wrong output, then - by definition - the code is not right!

So...use the debugger. Look at exactly what is happening. Work out what should happen before it does, and then compare that to what did happen. When it differs, you can start to work out why.

But I'm not doing it for you! This is a skill, and it really is worth developing, as you can use the same processes and mental techniques in the real world.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900