# include <iostream>
# include <string>
using namespace std;
void Upper(char&, string);
void Add(char&, int&, int&, int&, string);
void Replace(char&, int&, int&, string);
int main()
{
string s, t, r, u;
char a, b, c;
int n1, n2, n3, n4, n5;
cin >> s;
t = s;
Upper(a,t);
r = t;
Add(b, n1, n2, n3, r);
u = r;
Replace(c, n4, n5, u);
return 0;
}
void Upper(char& one, string ein)
{
one = ein.at(0);
one -= 32;
return;
}
void Add(char& two, int& second, int& third, int& forth, string zwei)
{
second = zwei.length();
third = 0;
forth = 0;
while (third < second)
{
two = zwei.at(third);
if (two == ' ')
{
forth += 1;
if (forth % 3 == 0)
{
zwei.at(third - 1) = '!';
}
else
{
continue;
}
}
else
{
continue;
}
third += 1;
}
return;
}
void Replace(char& three,int& fifth, int& sixth, string drei)
{
fifth = drei.length();
sixth = 0;
while (sixth < fifth)
{
three = drei.at(sixth);
if (three == '?' || three == '!')
{
drei.at(sixth) = '.';
}
else
{
continue;
}
sixth += 1;
}
cout << drei << endl;
return;
}
这个程序原本的目的是要把第一个字变成大写 在每3个字之间加入(:)把(!)或(?)换成。
# include <string>
using namespace std;
void Upper(char&, string);
void Add(char&, int&, int&, int&, string);
void Replace(char&, int&, int&, string);
int main()
{
string s, t, r, u;
char a, b, c;
int n1, n2, n3, n4, n5;
cin >> s;
t = s;
Upper(a,t);
r = t;
Add(b, n1, n2, n3, r);
u = r;
Replace(c, n4, n5, u);
return 0;
}
void Upper(char& one, string ein)
{
one = ein.at(0);
one -= 32;
return;
}
void Add(char& two, int& second, int& third, int& forth, string zwei)
{
second = zwei.length();
third = 0;
forth = 0;
while (third < second)
{
two = zwei.at(third);
if (two == ' ')
{
forth += 1;
if (forth % 3 == 0)
{
zwei.at(third - 1) = '!';
}
else
{
continue;
}
}
else
{
continue;
}
third += 1;
}
return;
}
void Replace(char& three,int& fifth, int& sixth, string drei)
{
fifth = drei.length();
sixth = 0;
while (sixth < fifth)
{
three = drei.at(sixth);
if (three == '?' || three == '!')
{
drei.at(sixth) = '.';
}
else
{
continue;
}
sixth += 1;
}
cout << drei << endl;
return;
}
这个程序原本的目的是要把第一个字变成大写 在每3个字之间加入(:)把(!)或(?)换成。