-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMPI.cpp
More file actions
80 lines (66 loc) · 1.95 KB
/
MPI.cpp
File metadata and controls
80 lines (66 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// MPI.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <iterator>
using namespace std;
struct IrisData {
double sepalLength;
double sepalWidth;
double petalLength;
double petalWidth;
std::string classification;
};
int main(int argc, char* argv[]) {
std::ifstream file("iris.dat");
//std::string line;
int count = 0;
for (std::string line; getline(file, line);) {
// temp values
double sepalLength;
double sepalWidth;
double petalLength;
double petalWidth;
// read each line and assign structs data
if (line.substr(0, 1) != "@") {
// print current line and return every iteration
//std::cout << line << "\n";
//string sentence = "And I feel fine...";
//istringstream iss(sentence);
//copy(istream_iterator<string>(iss),
// istream_iterator<string>(),
// ostream_iterator<string>(cout, "\n"));
// assign temps of temps
string sLength = line.substr(0, 3);
string sWidth = line.substr(5, 3);
string pLength = line.substr(10, 3);
string pWidth = line.substr(15, 3);
// assign temps
sepalLength = atof(sLength.c_str());
sepalWidth = atof(sWidth.c_str());
petalLength = atof(pLength.c_str());
petalWidth = atof(pWidth.c_str());
// assign iris data the temp values
IrisData irisData;
irisData.sepalLength = sepalLength;
irisData.sepalWidth = sepalWidth;
irisData.petalLength = petalLength;
irisData.petalWidth = petalWidth;
irisData.classification = "";
// print struct values
std::cout << count << ": \n";
std::cout << "Sepal Length: " << irisData.sepalLength << "\n";
std::cout << "Sepal Width: " << irisData.sepalWidth << "\n";
std::cout << "Petal Length: " << irisData.petalLength << "\n";
std::cout << "Petal Width: " << irisData.petalWidth << "\n";
count++;
}
}
system("pause");
}