Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65438195
main.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jun 3, 19:39
Size
1 KB
Mime Type
text/x-c
Expires
Wed, Jun 5, 19:39 (2 d)
Engine
blob
Format
Raw Data
Handle
18072149
Attached To
R7554 sp4e_exercices
main.cc
View Options
/* created by Marti Bosch and Marc Schwaerzel*/
/* -------------------------------------------------------------------------- */
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <sstream>
#include "compute_arithmetic.hh"
#include "compute_pi.hh"
#include "print_series.hh"
#include "series.hh"
#include "write_series.hh"
using
namespace
std
;
/* -------------------------------------------------------------------------- */
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
5
)
{
cout
<<
"Arguments: frequency, maxiter, series_type (arithmetic, pi), "
"dump_type (print, write)"
<<
endl
;
return
EXIT_FAILURE
;
}
std
::
stringstream
sstr
;
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
sstr
<<
argv
[
i
]
<<
" "
;
int
frequency
;
int
maxiter
;
string
series_type
;
string
dump_type
;
sstr
>>
frequency
;
sstr
>>
maxiter
;
sstr
>>
series_type
;
sstr
>>
dump_type
;
Series
*
series
;
if
(
series_type
==
"arithmetic"
)
series
=
new
ComputeArithmetic
();
else
if
(
series_type
==
"pi"
)
series
=
new
ComputePi
();
else
{
std
::
cout
<<
"input error"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
std
::
ofstream
of
(
"output.txt"
);
if
(
dump_type
==
"print"
)
{
PrintSeries
printseries
(
*
series
,
maxiter
,
frequency
);
printseries
.
dump
();
}
else
if
(
dump_type
==
"write"
)
{
WriteSeries
writeseries
(
*
series
,
maxiter
,
frequency
);
writeseries
.
dump
(
of
);
}
delete
series
;
}
Event Timeline
Log In to Comment