Click here to Skip to main content
15,908,906 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralOff-topic Pin
CPallini5-Jan-08 0:15
mveCPallini5-Jan-08 0:15 
GeneralRe: Off-topic Pin
toxcct5-Jan-08 7:25
toxcct5-Jan-08 7:25 
AnswerRe: how to set inlude of option? Pin
CPallini5-Jan-08 0:11
mveCPallini5-Jan-08 0:11 
GeneralRe: how to set inlude of option? Pin
gentleguy5-Jan-08 1:17
gentleguy5-Jan-08 1:17 
GeneralRe: how to set inlude of option? Pin
CPallini5-Jan-08 1:30
mveCPallini5-Jan-08 1:30 
GeneralRe: how to set inlude of option? Pin
gentleguy5-Jan-08 1:39
gentleguy5-Jan-08 1:39 
GeneralRe: how to set inlude of option? Pin
CPallini5-Jan-08 4:22
mveCPallini5-Jan-08 4:22 
GeneralRe: how to set inlude of option? Pin
gentleguy5-Jan-08 1:44
gentleguy5-Jan-08 1:44 
this is my all source code, i combined together, it can run smoothly, but i seperated, the problem is like above.

#include <iostream>
using std::endl;
using std::cin;
using std::cout;

#include <cstdlib>
using std::rand;
using std::srand;

#include <iomanip>
using std::setw;
using std::setprecision;
using std::ios;
using std::fixed;
using std::showpoint;
using std::setiosflags;

#include <ctime>
using std::time;


class Centroids
{

public:
void printArray(double a[3][4] )
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 4; j++)

cout << setw(3) << setprecision(6) << setiosflags(ios::fixed|ios::showpoint) << a[i][j] << " ";
cout << endl;

}

}
private:

double a[3][4];


};


int main()
{
Centroids matrix;
int number = 1;

for (int number = 1; number <=10; number++)
{

double a[3][4] = {{(double)rand()/RAND_MAX, (double)rand()/RAND_MAX, (double)rand()/RAND_MAX,( double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX}};

cout << setw(4) << number << endl;
matrix.printArray(a);
cout << endl;
}
number = number + 1;


return 0;
}


the following is what i seperated code above, can you help me to check? what is problem?

header file:

include <iostream>
using std::endl;
using std::cin;
using std::cout;


#include <iomanip>
using std::setw;
using std::setprecision;
using std::ios;
using std::fixed;
using std::showpoint;
using std::setiosflags;


class Centroids
{

public:
void printArray(double a[3][4] )
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 4; j++)

cout << setw(3) << setprecision(6) << setiosflags(ios::fixed|ios::showpoint) << a[i][j] << " ";
cout << endl;

}

}
private:

double a[3][4];


};



cpp code:


#include <iostream>
using std::endl;
using std::cin;
using std::cout;

#include <cstdlib>
using std::rand;
using std::srand;

#include <iomanip>
using std::setw;
using std::setprecision;
using std::ios;
using std::fixed;
using std::showpoint;
using std::setiosflags;

#include <ctime>
using std::time;
#include "Centroids.h"

int main()
{
Centroids matrix;
int number = 1;

for (int number = 1; number <=10; number++)
{

double a[3][4] = {{(double)rand()/RAND_MAX, (double)rand()/RAND_MAX, (double)rand()/RAND_MAX,( double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX}};

cout << setw(4) << number << endl;
matrix.printArray(a);
cout << endl;
}
number = number + 1;


return 0;
}

thanks a lot

Li Zhiyuan

5/10/2006

GeneralRe: how to set inlude of option? Pin
gentleguy5-Jan-08 1:47
gentleguy5-Jan-08 1:47 
GeneralRe: how to set inlude of option? Pin
David Crow5-Jan-08 4:33
David Crow5-Jan-08 4:33 
JokeRe: how to set inlude of option? Pin
CPallini5-Jan-08 4:35
mveCPallini5-Jan-08 4:35 
GeneralRe: how to set inlude of option? Pin
gentleguy6-Jan-08 0:07
gentleguy6-Jan-08 0:07 
GeneralAVCODEC Pin
Girish Kumar4-Jan-08 22:24
Girish Kumar4-Jan-08 22:24 
GeneralConvert Date to EXCEL Numeric Pin
im_hoser4-Jan-08 21:10
im_hoser4-Jan-08 21:10 
GeneralRe: Convert Date to EXCEL Numeric Pin
CPallini5-Jan-08 0:50
mveCPallini5-Jan-08 0:50 
GeneralProbelm in calling ActiveX VB dll Pin
manoharbalu4-Jan-08 19:35
manoharbalu4-Jan-08 19:35 
Generalurgent help Pin
gentleguy4-Jan-08 19:22
gentleguy4-Jan-08 19:22 
QuestionRe: urgent help Pin
CPallini4-Jan-08 23:09
mveCPallini4-Jan-08 23:09 
GeneralRe: urgent help Pin
gentleguy5-Jan-08 1:20
gentleguy5-Jan-08 1:20 
GeneralRe: urgent help Pin
Joan M5-Jan-08 2:14
professionalJoan M5-Jan-08 2:14 
QuestionProblem with using SENS and the COM Event System in VC++ Pin
ashishbhatt4-Jan-08 17:40
ashishbhatt4-Jan-08 17:40 
GeneralRe: Problem with using SENS and the COM Event System in VC++ Pin
David Crow4-Jan-08 17:50
David Crow4-Jan-08 17:50 
GeneralRe: Problem with using SENS and the COM Event System in VC++ Pin
ashishbhatt4-Jan-08 18:12
ashishbhatt4-Jan-08 18:12 
QuestionHow to get local ip address Pin
shakumar_224-Jan-08 17:18
shakumar_224-Jan-08 17:18 
AnswerRe: How to get local ip address Pin
David Crow4-Jan-08 17:46
David Crow4-Jan-08 17:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.