Created
May 25, 2012 23:30
-
-
Save lazyval/2791174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" | |
#include <iostream> | |
#include <fstream> | |
#include <string> | |
using namespace std; | |
void readFromFile() { | |
string line; | |
ifstream myfile ("tolstoy.txt"); | |
if (myfile.is_open()) | |
{ | |
while ( myfile.good() ) | |
{ | |
getline (myfile,line); | |
printf(line.c_str()); | |
} | |
myfile.close(); | |
} | |
else printf("Unable to open file"); | |
} | |
float calculateParam(int n, float*Uvix) | |
{ | |
/*float min = Uvix[0], max = Uvix[0]; | |
for(unsigned int i = 0; i < n; i++) | |
if(Uvix[i]>max) max=Uvix[i]; | |
for(unsigned int i = 0; i < n; i++) | |
if (Uvix[i]<min) min=Uvix[i]; | |
return max - min;*/ | |
} | |
void writeToFile(int n, float* Uvix) { | |
ofstream myfile; | |
myfile.open ("example.txt"); | |
for(int i = 0; i < n; i++) { | |
myfile << Uvix[i] << endl; | |
} | |
myfile.close(); | |
} | |
int main(int argc, char** argv) | |
{ | |
while(true) { | |
// read from console? | |
const int action = (int)argv[1] - 48; | |
switch(action) { | |
case 1: readFromFile(); break; | |
case 2: float p = calculateParam(); break; | |
// ... | |
default: printf("ERROR! Illegal # of operation. Choose number between 1 and 5."); break; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment