110 lines
2.1 KiB
C
110 lines
2.1 KiB
C
#include "stdio.h"
|
|
#include "Windows.h"
|
|
|
|
#define MAX_LEN 80
|
|
char s[MAX_LEN];
|
|
|
|
void Z1html(), Z2html();
|
|
|
|
int main() {
|
|
SetConsoleCP(1251);
|
|
SetConsoleOutputCP(1251);
|
|
|
|
Z1html();
|
|
Z2html();
|
|
|
|
return 0;
|
|
}
|
|
|
|
void Z1html() {
|
|
FILE* fin;
|
|
fopen_s(&fin, "D:\\university\\ÎÀÈÏ\\lab\\Temp\\23-24\\in1html.txt", "rt");
|
|
if (fin == NULL) {
|
|
printf("Âõîäíîé ôàéë íå íàéäåí");
|
|
return;
|
|
}
|
|
|
|
FILE* fout;
|
|
fopen_s(&fout, "D:\\university\\ÎÀÈÏ\\lab\\Temp\\23-24\\out1html.html", "wt");
|
|
if (fout == NULL) {
|
|
printf("Âûõîäíîé ôàéë íå ñîçäàëñÿ");
|
|
return;
|
|
}
|
|
|
|
fprintf(fout, "<!DOCTYPE html><html><head><meta http - equiv = \"Content-Type\" content = \"text/html; charset=utf-8\"/><title>HTML Document</title></head><body>");
|
|
|
|
while (!feof(fin)) {
|
|
if (fgets(s, MAX_LEN, fin) != NULL) {
|
|
fprintf(fout, "%s<br>", s);
|
|
}
|
|
}
|
|
|
|
fprintf(fout, "</body></html>");
|
|
|
|
fclose(fin);
|
|
fclose(fout);
|
|
}
|
|
|
|
void Z2html() {
|
|
FILE* fin;
|
|
fopen_s(&fin, "D:\\university\\ÎÀÈÏ\\lab\\Temp\\23-24\\in2html.txt", "rt");
|
|
if (fin == NULL) {
|
|
printf("Âõîäíîé ôàéë íå íàéäåí");
|
|
return;
|
|
}
|
|
|
|
FILE* fout;
|
|
fopen_s(&fout, "D:\\university\\ÎÀÈÏ\\lab\\Temp\\23-24\\out2html.html", "wt");
|
|
if (fout == NULL) {
|
|
printf("Âûõîäíîé ôàéë íå ñîçäàëñÿ");
|
|
return;
|
|
}
|
|
|
|
fprintf(fout, "<!DOCTYPE html><html><head><meta http - equiv = \"Content-Type\" content = \"text/html; charset=utf-8\"/><title>HTML Document</title></head><body>");
|
|
|
|
while (!feof(fin)) {
|
|
if (fgets(s, MAX_LEN, fin) != NULL) {
|
|
int bold = 0;
|
|
for (int i = 0; s[i] != '\0'; i++) {
|
|
if (s[i + 1] == '\0') break;
|
|
for (int j = i+1; s[j] != '\0'; j++) {
|
|
if (s[i] == s[j]) {
|
|
bold = 1;
|
|
break;
|
|
}
|
|
}
|
|
if (bold) break;
|
|
}
|
|
|
|
|
|
|
|
int italic = 1;
|
|
for (int i = 0; s[i] != '\0'; i++) {
|
|
if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'à' && s[i] <= 'ÿ'))
|
|
{
|
|
italic = 0;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (bold && italic) {
|
|
fprintf(fout, "<i><b>%s</b></i><br>", s);
|
|
continue;
|
|
}
|
|
if (bold) {
|
|
fprintf(fout, "<b>%s</b><br>", s);
|
|
continue;
|
|
}
|
|
if (italic) {
|
|
fprintf(fout, "<i>%s</i><br>", s);
|
|
continue;
|
|
}
|
|
fprintf(fout, "%s<br>", s);
|
|
}
|
|
}
|
|
|
|
fprintf(fout, "</body></html>");
|
|
|
|
fclose(fin);
|
|
fclose(fout);
|
|
} |