forked from srinivas9804/Competitive-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLongestWord110.cpp
More file actions
32 lines (31 loc) · 719 Bytes
/
LongestWord110.cpp
File metadata and controls
32 lines (31 loc) · 719 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
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char word[101];
char largest[101];
int length = 0;
cin >> word;
while (strcmp(word,"E-N-D")) {
int l = 0;
for (int i = 0; word[i] != '\0'; i++) {
if ((word[i] >= 'a' && word[i] <= 'z') || (word[i] >= 'A' && word[i] <= 'Z') || word[i] == '-')
l++;
if (word[i] >= 'A' && word[i] <= 'Z')
word[i] += 'a' - 'A';
}
//cout << word << " " << endl;
if (l > length) {
strcpy(largest, word);
length = l;
}
cin >> word;
}
for (int i = 0; largest[i] != '\0'; i++) {
if ((largest[i] >= 'a'&&largest[i] <= 'z')||largest[i]=='-')
cout << largest[i];
}
cout << endl;
return 0;
}