diff options
author | Santo Cariotti <sancn@live.com> | 2017-04-26 16:37:39 +0200 |
---|---|---|
committer | Santo Cariotti <sancn@live.com> | 2017-04-26 16:37:39 +0200 |
commit | 483d63fa7249ad8d6020680c48c3cf6df35010b3 (patch) | |
tree | 2f8649e3ae6b42ace5011246285c9c450f004222 /cpp/biblioteca.cc | |
parent | 6c957dc4e01aee6ce9cae3c8342d04b0fd9ca9c4 (diff) |
Moved all C++ files into CPP folder
Diffstat (limited to 'cpp/biblioteca.cc')
-rw-r--r-- | cpp/biblioteca.cc | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/cpp/biblioteca.cc b/cpp/biblioteca.cc new file mode 100644 index 0000000..85cd80f --- /dev/null +++ b/cpp/biblioteca.cc @@ -0,0 +1,57 @@ +#include <iostream> +#include <fstream> +#include <sstream> +#include <time.h> + +using namespace std; + +int main(void) +{ + ifstream filein; + ofstream fileout; + + filein.open("input.txt"); + fileout.open("output.txt"); + + time_t rawtime; + struct tm * timeinfo; + + int num[4], i = 0, j = 1, diff, tot[2]; + char ch; + string cc; + + while(!filein.eof()) + { + filein.get(ch); + if(ch != ' '){ + cc+=ch; + istringstream(cc) >> num[i]; + }else { + i++; + cc = ""; + } + } + + time(&rawtime); + timeinfo = localtime(&rawtime); + + for(i = 0; i < 2; i++){ + timeinfo->tm_year = 2001-1900; + timeinfo->tm_mon = num[j]-1; + timeinfo->tm_mday = num[j-1]; + + mktime(timeinfo); + + tot[i] = timeinfo->tm_yday+1; + j = 3; + } + + diff = tot[1] - tot[0]; + + fileout << diff; + + filein.close(); + fileout.close(); + + return 0; +} |