-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNITIKA.cpp
More file actions
executable file
·98 lines (89 loc) · 2.08 KB
/
Copy pathNITIKA.cpp
File metadata and controls
executable file
·98 lines (89 loc) · 2.08 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include<iostream>
#include<string.h>
#include<ctype.h>
using namespace std;
int main()
{
int t;
cin>>t;
cin.ignore();
while(t--)
{
string s;
getline(cin,s);
char name[12],c,ch1,ch2;
int c1=0;
for(int i=0;s[i]!='\0';i++)
{
if(s[i]==' ')
c1++;
}
if(c1==0)
{
c=toupper(s[0]);
name[0]=c;
int i;
for(i=1;s[i]!='\0';i++)
{
c=tolower(s[i]);
name[i]=c;
}
name[i]='\0';
cout<<name<<endl;
}
else if(c1==1)
{
ch1=toupper(s[0]);
int j=0;
int flag=0;
for(int i=1;s[i]!='\0';i++)
{
if(s[i]==' ')
{
flag=1;
i++;
name[j]=toupper(s[i]);
j++;
}
else if(flag)
{
c=tolower(s[i]);
name[j]=c;
j++;
}
}
name[j]='\0';
cout<<ch1<<". "<<name<<endl;
}
else
{
ch1=toupper(s[0]);
int j=0;
int flag=0;
for(int i=1;s[i]!='\0';i++)
{
if(s[i]==' '&&flag==0)
{
i++;
ch2=toupper(s[i]);
flag=1;
}
else if(flag==1&&s[i]==' ')
{
flag=2;
i++;
name[j]=toupper(s[i]);
j++;
}
else if(flag==2)
{
c=tolower(s[i]);
name[j]=c;
j++;
}
}
name[j]='\0';
cout<<ch1<<". "<<ch2<<". "<<name<<endl;
}
}
}