Due semplici contatori: uno da terminale, l'altro da file.
//Contatore
# include < iostream >
# include < fstream >
# include "math.h"
# include "funz.h"
# define NMAX 100000
using namespace std;
//---Contatore da terminale---
/*
int main(){
double numbers[NMAX];
int i = 0;
int N = 0;
for(;;){
cin >> N;
if( cin.eof() ) break;
numbers[i] = N;
i++;
}
cout << "numero = " << i << endl;
return 0;
}
*/
//---Contatore da file---
/*
int main(){
double numbers[NMAX];
int i = 0;
ifstream f("dat.dat");
for(;;){
f >> numbers[i];
if( f.eof() ) break;
i++;
}
cout << "numero = " << i << endl;
f.close();
return 0;
}
*/
Categories:
Programmi
Posta un commento