#include <iostream>
#include <string.h>
using namespace std;
#define MAX 300
void ChenChuoiTaiVitriK(char s[], char s1[], int k);
void Chuanhoa(char s[]);
int myStrlen(char s[], int k);
bool myStrcat(char s[], char s1[], char s2[]);
void myStrcpy(char s[], int vt, char s1[], int k);
int myStrstr(char s[], char s1[]);
int main()
{
if(fopen("ben.inp", "r")){
freopen("ben.inp", "r", stdin);
freopen("ben.out", "w", stdout);
}
char s[MAX];
fflush(stdin);
cin.getline(s, MAX);
char s1[MAX];
myStrcpy(s1, 0, s, 0);
Chuanhoa(s1);
cout << s << endl << s1 << endl;
return 0;
}
//return length of string s start from s[k]
int myStrlen(char s[], int k){
int cnt = 0;
while(s[k++] != '\0') cnt++;
return cnt;
}
//append string s2 to string s1
bool myStrcat(char s[], char s1[], char s2[]){
int len1 = myStrlen(s1, 0);
int len2 = myStrlen(s2, 0);
int len = len1 + len2;
for(int i = 0; i < len1; i++){
s[i] = s1[i];
}
for(int i = len1; i < len; i++){
s[i] = s2[i - len1];
}
s[len] = '\0';
return true;
}
//create string s from string s1 start from s1[k]
void myStrcpy(char s[], int vt, char s1[], int k){
//s = s1[k...len - 1]
int len = myStrlen(s1, k);
for(int i = 0; i < len; i++){
s[i] = s1[k + i];
}
s[len] = '\0';
}
//return the first occurrence of string s1 in string s
//return the size of string s if string s1 does not occur in string s
int myStrstr(char s[], char s1[]){
int n = myStrlen(s, 0);
int m = myStrlen(s1, 0);
for(int i = 0; i <= n - m; i++){
bool satisfied = true;
for(int j = i; j < i + m; j++){
if(s[j] != s1[j - i]){
satisfied = false;
break;
}
}
if(satisfied) return i;
}
return n;
}
void Chuanhoa(char s[]){
char dot[] = ".";
int dot_pos = myStrstr(s, dot);
int n = myStrlen(s, 0);
int l, r;
char res[MAX];
while(dot_pos != n){
l = r = dot_pos;
while(l - 1 >= 0 && s[l - 1] == ' ') l--;
while(r + 1 < n && s[r + 1] == ' ') r++;
char lt[MAX];
myStrcpy(lt, 0, s, 0);
lt[l] = '.';
lt[l + 1] = '\0';
myStrcat(res, res, lt);
if(r + 1 == n) break;
myStrcat(res, res, " ");
myStrcpy(s, 0, s, r + 1);
dot_pos = myStrstr(s, dot);
n = myStrlen(s, 0);
}
myStrcpy(s, 0, res, 0);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgTUFYIDMwMAoKdm9pZCBDaGVuQ2h1b2lUYWlWaXRyaUsoY2hhciBzW10sIGNoYXIgczFbXSwgaW50IGspOwp2b2lkIENodWFuaG9hKGNoYXIgc1tdKTsKaW50IG15U3RybGVuKGNoYXIgc1tdLCBpbnQgayk7CmJvb2wgbXlTdHJjYXQoY2hhciBzW10sIGNoYXIgczFbXSwgY2hhciBzMltdKTsKdm9pZCBteVN0cmNweShjaGFyIHNbXSwgaW50IHZ0LCBjaGFyIHMxW10sIGludCBrKTsKaW50IG15U3Ryc3RyKGNoYXIgc1tdLCBjaGFyIHMxW10pOwoKCmludCBtYWluKCkKewogICAgaWYoZm9wZW4oImJlbi5pbnAiLCAiciIpKXsKICAgICAgICBmcmVvcGVuKCJiZW4uaW5wIiwgInIiLCBzdGRpbik7CiAgICAgICAgZnJlb3BlbigiYmVuLm91dCIsICJ3Iiwgc3Rkb3V0KTsKICAgIH0KCWNoYXIgc1tNQVhdOwoKCWZmbHVzaChzdGRpbik7CgljaW4uZ2V0bGluZShzLCBNQVgpOwoKCWNoYXIgczFbTUFYXTsKCW15U3RyY3B5KHMxLCAwLCBzLCAwKTsKCUNodWFuaG9hKHMxKTsKCWNvdXQgPDwgcyA8PCBlbmRsIDw8IHMxIDw8IGVuZGw7CglyZXR1cm4gMDsKfQoKLy9yZXR1cm4gbGVuZ3RoIG9mIHN0cmluZyBzIHN0YXJ0IGZyb20gc1trXQppbnQgbXlTdHJsZW4oY2hhciBzW10sIGludCBrKXsKICAgIGludCBjbnQgPSAwOwogICAgd2hpbGUoc1trKytdICE9ICd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ICAgIGZvcihpbnQgaSA9IDA7IGkgPD0gbiAtIG07IGkrKyl7CiAgICAgICAgYm9vbCBzYXRpc2ZpZWQgPSB0cnVlOwogICAgICAgIGZvcihpbnQgaiA9IGk7IGogPCBpICsgbTsgaisrKXsKICAgICAgICAgICAgaWYoc1tqXSAhPSBzMVtqIC0gaV0pewogICAgICAgICAgICAgICAgc2F0aXNmaWVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZihzYXRpc2ZpZWQpIHJldHVybiBpOwogICAgfQogICAgcmV0dXJuIG47Cn0KCnZvaWQgQ2h1YW5ob2EoY2hhciBzW10pewogICAgY2hhciBkb3RbXSA9ICIuIjsKICAgIGludCBkb3RfcG9zID0gbXlTdHJzdHIocywgZG90KTsKICAgIGludCBuID0gbXlTdHJsZW4ocywgMCk7CiAgICBpbnQgbCwgcjsKCiAgICBjaGFyIHJlc1tNQVhdOwoKICAgIHdoaWxlKGRvdF9wb3MgIT0gbil7CiAgICAgICAgbCA9IHIgPSBkb3RfcG9zOwogICAgICAgIHdoaWxlKGwgLSAxID49IDAgJiYgc1tsIC0gMV0gPT0gJyAnKSBsLS07CiAgICAgICAgd2hpbGUociArIDEgPCBuICYmIHNbciArIDFdID09ICcgJykgcisrOwoKICAgICAgICBjaGFyIGx0W01BWF07CiAgICAgICAgbXlTdHJjcHkobHQsIDAsIHMsIDApOwogICAgICAgIGx0W2xdID0gJy4nOwogICAgICAgIGx0W2wgKyAxXSA9ICdcMCc7CgogICAgICAgIG15U3RyY2F0KHJlcywgcmVzLCBsdCk7CgogICAgICAgIGlmKHIgKyAxID09IG4pIGJyZWFrOwoKICAgICAgICBteVN0cmNhdChyZXMsIHJlcywgIiAiKTsKCiAgICAgICAgbXlTdHJjcHkocywgMCwgcywgciArIDEpOwoKICAgICAgICBkb3RfcG9zID0gbXlTdHJzdHIocywgZG90KTsKICAgICAgICBuID0gbXlTdHJsZW4ocywgMCk7CiAgICB9CgogICAgbXlTdHJjcHkocywgMCwgcmVzLCAwKTsKfQoK