Anonymous user
Text processing/Max licenses in use: Difference between revisions
Text processing/Max licenses in use (view source)
Revision as of 21:48, 24 February 2011
, 13 years ago→{{header|C++}}: Added correct solution
m (Remove "incomplete" message) |
(→{{header|C++}}: Added correct solution) |
||
Line 301:
=={{header|C++}}==
#include <iterator>
▲<lang cpp>#include <iostream>
#include <string>
▲#include <fstream>
#include <vector>
int main(
{
if ( argc != 2 ) {▼
const char logfilename[] = "mlijobs.txt";
std::ifstream logfile(logfilename);
}▼
{
▲ }
int
std::vector<std::string>
▲ if ( infile.is_open( ) ) {
for (std::string logline; std::getline(logfile, logline); )
std::string action(logline.substr(8,3));
if (action == "OUT")
if (++license >= max_license)
if (license > max_license)
max_license = license;
max_timestamp.clear();
}
max_timestamp.push_back(logline.substr(14, 19));
}
else if (action == "IN ")
}
▲ std::cout << "Could not open " << argv[ 1 ] << " !\n" ;
std::cout << "License count at log end: " << license
▲ }
<< "\nMaximum simultaneous license: " << max_license
<< "\nMaximum license time(s):\n";
</lang>▼
std::copy(max_timestamp.begin(), max_timestamp.end(),
std::ostream_iterator<std::string>(std::cout, "\n"));
▲}</lang>
Output:<pre>License count at log end: 0
Maximum simultaneous licenses: 99
Maximum license time(s):
2008/10/03_08:39:34
2008/10/03_08:40:40</pre>
=={{header|C sharp|C#}}==
|