Skip to content

Commit 5dfdcdb

Browse files
authored
Merge pull request Astrodevil#258 from Shawata-mondal/main
LeetCode problem no 412 solution in Cpp added
2 parents 22c659e + 1bf34d3 commit 5dfdcdb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

C++/Fizz_Buzz.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
vector<string> fizzBuzz(int n) {
4+
vector<string>ans;
5+
for(int i=1;i<=n;i++)
6+
{
7+
if((i)%15==0)
8+
{
9+
string str="FizzBuzz";
10+
ans.push_back(str);
11+
}
12+
else if((i)%5==0){
13+
string str="Buzz";
14+
ans.push_back(str);
15+
}
16+
else if((i)%3==0){
17+
string str="Fizz";
18+
ans.push_back(str);
19+
}
20+
else
21+
ans.push_back(to_string(i));
22+
}
23+
return ans;
24+
}
25+
int main()
26+
{
27+
vector<string> answer= fizzBuzz(5);
28+
}

0 commit comments

Comments
 (0)