-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandomstuff.cpp
44 lines (40 loc) · 969 Bytes
/
randomstuff.cpp
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
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <random>
#include <algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <cctype>
using namespace std;
string CreateAcronym(string userPhrase)
{
vector<string> acronymLetters;
if (isupper(userPhrase[0]))
{
acronymLetters.push_back(string(1, userPhrase[0]));
}
for (int i = 1; i < userPhrase.size(); i++)
{
if (string(1, userPhrase[i]) == " " && isupper(userPhrase[i + 1]))
{
acronymLetters.push_back(string(1, userPhrase[i + 1]));
}
}
string acronym = "";
for (int j = 0; j < acronymLetters.size(); j++)
{
string letter = acronymLetters.at(j);
acronym = acronym + letter + ".";
}
return acronym;
}
int main()
{
string name;
cout << "enter phrase: " << endl;
getline(cin, name);
string acronym = CreateAcronym(name);
cout << acronym << endl;
}