-
Notifications
You must be signed in to change notification settings - Fork 18
/
Fizzstring.cs
51 lines (49 loc) · 1.26 KB
/
Fizzstring.cs
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
48
49
50
51
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication175
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter the string");
string s = Console.ReadLine();
int i, L,start=0,end=0;
char[] a = s.ToCharArray();
L = a.Length;
for (i = 0; i < L; i++)
{
if ((a[i] == 'f'||a[i]=='F')&&i==0)
{
start++;
}
if ((a[i] == 'b'||a[i]=='B')&&(i==L-1))
{
end++;
}
}
Console.WriteLine("\n");
if (start == 1 && end == 0)
{
Console.WriteLine("Fizz");
}
else if (start == 0 && end == 1)
{
Console.WriteLine("Buzz");
}
else if (start == 1 && end == 1)
{
Console.WriteLine("FizzBuzz");
}
else
{
Console.WriteLine(s);
}
Console.WriteLine("\n");
Console.ReadLine();
}
}
}