Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
3
Indexable
Never

#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()
{
	char s[MAX];

	fflush(stdin);
	fgets(s, 300, stdin);

	char s1[MAX];
	myStrcpy(s1, 0, s, 0);
	Chuanhoa(s1);
	puts(s);
	puts(s1);
	return 0;
}

int myStrlen(char s[], int k) {
	int i = 0;
	while (s[i] != '\0')
		i++;
	return i;
}

void myStrcpy(char s[], int vt, char s1[], int k) {
	for (int i = 0; i < myStrlen(s, 0); i++)
		s1[i] = s[i];
}

void Chuanhoa(char s[]) {
	for (int i = 0; i < myStrlen(s,0); i++)
		if (s[i] == '.') {
			int j = i;
			// xóa dấu cách phía trc
			while (true) {
				if (s[j] == ' '){
					for (int k = j; k < myStrlen(s, 0); k++)
						s[k] = s[k + 1];
                    j--;
                    }
				else break;
			}
			// xóa dấu cách phia sau
			while (true) {
				j++;
				if (s[j] == ' ')
					for (int k = j; k < myStrlen(s, 0); k++)
						s[k] = s[k + 1];
				else break;
			}
		}
}