#include <iostream>
#include <fstream>
using namespace std;
int main() {
fstream my_file;
double num[100];
int i=0;
my_file.open("text.txt");
if (!my_file) {
cout << "No such file";
}
else {
double n;
while (1) {
my_file >> n;
num[i]=n;
if (my_file.eof())
break;
i++;
}
}
double min=num[0];
double max=num[0];
for(int j=0;j<=i;j++){
if (num[j]<min)
min=num[j];
}
for(int j=0;j<=i;j++){
if (num[j]>max)
max=num[j];
}
cout<<"\nSmallest: "<<min;
cout<<"\nLargest: "<<max;
my_file.close();
return 0;
}
Comments
Leave a comment