-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFizzBuzz.cpp
More file actions
47 lines (44 loc) · 758 Bytes
/
Copy pathFizzBuzz.cpp
File metadata and controls
47 lines (44 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <fstream>
#include <vector>
#include <sstream>
using namespace std;
void fizzBuzz(int a, int b, int range)
{
for (int i = 1; i <= range; ++i)
{
if (i%a == 0 && i%b ==0)
cout << "FB ";
else
if (i%a == 0)
cout << "F ";
else
if (i%b == 0)
cout << "B ";
else
cout << i << " ";
}
cout << endl;
}
int main(int argc,char *argv[])
{
string token;
ifstream ifs(argv[1]);
if (ifs.is_open())
{
while (getline(ifs, token))
{
string token1;
vector<string> vs;
stringstream ss(token);
while (getline(ss, token1, ' '))
vs.push_back(token1);
fizzBuzz(stoi(vs[0]), stoi(vs[1]), stoi(vs[2]));
}
}
system("pause");
return 0;
}