Here is what I have

#include <iostream.h>

int main() {
    int i, total[3];
    int myValue[3][3];

myValue[0][0] = 53,000;
myValue[0][1] = 5;
myValue[0][2] = 1;


myValue[1][0] = 89,000;
myValue[1][1] = 3;
myValue[1][2] = 2;

myValue[2][0] = 93,000;
myValue[2][1] = 3;
myValue[2][2] = 3;



    for (i = 0; i < 3; i++)
    {
        total[i] = (myValue[i][0]/1000) + (myValue[i][1] - myValue[i][2]);
    }

cout << total[i] <<endl;
    return 0;

}

For some reason, I can't get the array to print at all.....It justcomes up with the initial value of 3, Im fairly new to programming.

Original Problem

I have the formula A/1000 + B - C. I need write a program that readsa the file and determines a priority number (like above). Then the prorgam needs to build a priority queue using the priority number and prints a list in accending order.

Here is what I have

#include <iostream.h>

int main() {
int i, total[3];
int myValue[3][3];

myValue[0][0] = 53,000;
myValue[0][1] = 5;
myValue[0][2] = 1;


myValue[1][0] = 89,000;
myValue[1][1] = 3;
myValue[1][2] = 2;

myValue[2][0] = 93,000;
myValue[2][1] = 3;
myValue[2][2] = 3;

for (i = 0; i < 3; i++)
{
total = (myValue[0]/1000) + (myValue[1] - myValue[2]);
}

cout << total <<endl;
return 0;

}


For some reason, I can't get the array to print at all.....It justcomes up with the initial value of 3, Im fairly new to programming.

Original Problem

I have the formula A/1000 + B - C. I need write a program that readsa the file and determines a priority number (like above). Then the prorgam needs to build a priority queue using the priority number and prints a list in accending order.

Try this

int i, total[3];
	int myValue[3][3];

	myValue[0][0] = 53000;
	myValue[0][1] = 5;
	myValue[0][2] = 1;


	myValue[1][0] = 89000;
	myValue[1][1] = 3;
	myValue[1][2] = 2;

	myValue[2][0] = 93000;
	myValue[2][1] = 3;
	myValue[2][2] = 3;

	for (i = 0; i < 3; i++)
	{
		total[i] = (myValue[i][0]/1000) + (myValue[i][1] - myValue[i][2]);
	}

	cout << total[0] <<endl;
	cout << total[1] <<endl;
	cout << total[2] <<endl;

Don't put commas in the numeric figures.

Alright thats awesome....But I have a small problem now. I forgot to add another variable. I need to add a name to each array I have. But can I have char and a int at the same time?

try this,

struct SData
{
	char  	name[128];
	int 	Values[3];
};

SData myData[3];

strcpy( myData[0].name , "Name 1");
myData[0].Values[0] = 1;
myData[0].Values[1] = 2;
myData[0].Values[2] = 3;

strcpy( myData[1].name , "Name 2");
myData[1].Values[0] = 4;
myData[1].Values[1] = 5;
myData[1].Values[2] = 6;

strcpy( myData[2].name , "Name 3");
myData[2].Values[0] = 7;
myData[2].Values[1] = 8;
myData[2].Values[2] = 9;

int total[3];
for (int i = 0; i < 3; i++)
	total[i] = myData[i].Values[0] + myData[i].Values[1] + myData[i].Values[2];

cout << total[0] << endl << total[1] << end << total[2] << endl;

The code may contain some typo errors, haven't compiled it, just typed it. Btw, is it an assignmnet? Are you allowed to use STL???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.