منتدى برامج نت | برامج نت | دليل المواقع | العاب فلاش | برامج | عيادة الطب | Free software
العاب افلام موقع منتديات

المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : I need a help in this problem ASAP


shayeeto
12-20-2006, 03:37 AM
// Manufacturing’s typical statistical quality-control program

/* when executed, shows the distribution of component failures on manufacturing of electronic boards having 5 components */

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cassert>
using namespace std;

void readFileData (int dist[ ]) ;
void deliverResults (int dist[ ]);
const int SIZE = 6 ; // select problem dimensionality
int dist [SIZE] ; // declare & instantiate the array

// This is the entry point for this application
int main()
{
readFileData (&dist[SIZE]) ;
deliverResults (&dist[SIZE]) ;
return 0;
}

void readFileData (int dist[ ])
{
int board_counter = 0, failures = 0;
cout << "enter name of input file "<<endl;
string inputFileName;
getline(cin,inputFileName);
ifstream inStream;

inStream.open(inputFileName.data());
assert(inStream.is_open());
for(;;)
{
inStream >> failures;
if(inStream.eof()) break;
dist [failures]++;
board_counter++;
cout << "total number of observations read = " << board_counter << endl;
}

inStream.close();
}

void deliverResults (int dist[ ])
{
cout << "failure results follow the following frequency distribution "<<endl;
cout << "enter name of output file "<<endl;
string outputFileName;
getline(cin,outputFileName);
ofstream oStream;

oStream.open(outputFileName.data());
assert(oStream.is_open());
for (int i = 0; i < SIZE; i++)
{
oStream << i << " failures have frequency " << dist [i] <<endl;
}

oStream.close();
}
-------------------------------------------------------------

this is a program that we have to use to do another program by making some changes in this program...

the q is:
this tiny program(the program that we have to write) must be able to read squential data of type" real" from data file, the program must read from the following data source stored in input data file called"datafile.dat" having 2 separet data sets labled "A" and "B" which you could presumbly store anywhere.
compute the euclidean distance between A and B using the 2 sets:
A:
1244548011
13
45
65
45
340002175
34
-56
23
34
-45
974777023
B:
123330808
33
47
77
88
340001111
34
94
66
-55
12
345655672

Euclideans distance is:
d=|b-a|