-
Notifications
You must be signed in to change notification settings - Fork 18
/
Capitalization.cs
47 lines (45 loc) · 1.16 KB
/
Capitalization.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication206
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Capitalization");
Console.WriteLine("Enter the string:");
string s = Console.ReadLine();
char[] a = s.ToCharArray();
int i, L,count=0;
L = a.Length;
for (i = 0; i < L; i++)
{
if (a[i] == ' ')
{
count++;
continue;
}
else if (count == 2)
{
count++;
a[i] = (char)(a[i] - 32);
}
else if (count == 0)
{
count++;
a[i] = (char)(a[i] - 32);
}
}
Console.WriteLine("\n");
for (i = 0; i < L; i++)
{
Console.Write("{0}", a[i]);
}
Console.WriteLine("\n");
Console.ReadLine();
}
}
}