Skip to content
Snippets Groups Projects
Commit e34520c7 authored by Ross Netusil's avatar Ross Netusil
Browse files

new files

parent de7d22ce
No related branches found
No related tags found
No related merge requests found
File added
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
int main(int argc, char **argv)
{
if (argc == 1) //No filename was entered.
{
std::cout << "No_Filename_Given._Exiting." << std::endl;
return 1;
}
if (argc > 2) //Too many arguments given.
{
std::cout << "More_than_one_filename_given._Exiting." << std::endl;
return 1;
}
std::ifstream infile(argv[1]);
if (infile)
{
{float a,Min=1000000,Max=0,Sum=0,Mean,Entries=0; //Define as float a, Min, Max, Sum, Mean, Entries, and set initial values for Min, Max, Sum, Entries.
while (infile >> a) //Set a == value on the next line in file.
{
Min = (std::min(a,Min));
Max = (std::max(a,Max));
Sum += a;
Entries++;}
Mean = Sum/Entries;
std::cout << "Entries: " << Entries << "_;";
std::cout << "Max: " << Max << "_;";
std::cout << "Min: " << Min << "_;";
std::cout << "Sum: " << Sum << "_;";
std::cout << "Mean: " << Mean << "." << std::endl; // Report Values
return 0
;}}
else
{
std::cout << "Can_not_Open_File. " << argv[1] << std::endl; //Unable to open file.
return 1
; }
}
#include <iostream>
#include <fstream>
int main(int argc, char **argv)
{
if (argc == 1) //No filename was entered.
{
std::cout << "No_Filename_Given._Exiting." << std::endl;
return 1;
}
if (argc > 2) //Too many arguments given.
{
std::cout << "More_than_one_filename_given._Exiting." << std::endl;
return 1;
}
std::ifstream infile(argv[1]);
if (infile)
{
double sum = 0;
double a = 0;
double i;
while (infile >> i)
{
double y = i-a
double t = sum + i
a = (t - sum)-y
sum = t
std::cout << sum << "\n"
}
}
return 0
;}}
else
{
std::cout << "Can_not_Open_File. " << argv[1] << std::endl; //Unable to open file.
return 1
; }
}
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
int main(int argc, char **argv)
{
std::vector<double> vec;
if (argc == 1) //No filename was entered.
{
std::cout << "No_Filename_Given._Exiting." << std::endl;
return 1;
}
if (argc > 2) //Too many arguments given.
{
std::cout << "More_than_one_filename_given._Exiting." << std::endl;
return 1;
}
std::ifstream infile(argv[1]);
if (infile)
{
{float a,Min=1000000,Max=0,Sum=0,Mean,Entries=0; //Define as float a, Min, Max, Sum, Mean, Entries, and set initial values for Min, Max, Sum, Entries.
while (infile >> a) //Set a == value on the next line in file.
{
vec.push_back(a);
if (a > Max) Max=a;
if (a < Min) Min=a;
Sum += a;
Entries++;}
Mean = Sum / Entries;
std::cout << "Entries: " << vec.size() << "_;";
std::cout << "Max: " << Max << "_;";
std::cout << "Min: " << Min << "_;";
std::cout << "Sum: " << Sum << "_;";
std::cout << "Mean: " << Mean << "." << std::endl; // Report Values
return 0
;}}
else
{
std::cout << "Can_not_Open_File. " << argv[1] << std::endl; //Unable to open file.
return 1
; }
}
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment