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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
#include <fstream>
#include <iostream>
using namespace std;
int main ()
{
char c, vards[40], replaase[40][2][40];
int count, burts, x=0, y=0, z=0, i,h;
FILE * pf1, * pf2, * pf3;
pf1 = fopen ("f1", "r");
pf2 = fopen ("f2", "r");
pf3 = fopen ("f3", "w");
count = 0;
do
{
c = fgetc (pf2); // ielasa
if (c == EOF)
{
for (; z<40; z++)
{
replaase[x][y][z] = ' ';
}
break;
} else if (c == ',')
{
for (; z<40; z++)
{
replaase[x][y][z] = ' ';
}
z = 0;
y = 1;
} else if (c == '\n')
{
for (; z<40; z++)
{
replaase[x][y][z] = ' ';
}
z = 0;
y = 0;
x++;
} else
{
replaase[x][y][z] = c;
z++;
}
} while (c != EOF);
count = x;
for (x=0; x<=count; x++)
{
for (z=0; z<40; z++)
{
cout << replaase[x][0][z];
}
for (z=0; z<40; z++)
{
cout << replaase[x][1][z];
}
cout << endl;
}
burts = 0;
do
{
c = fgetc (pf1); // ielasa
if (c== EOF || c==' ' || c=='.' || c==',' || c=='(' || c==')' || c=='!' || c=='?')
{
atrada = false;
for (; burts<40; burts++)
{
vards[burts] = ' ';
}
for (h=0; h<=count; h++)
{
for (i=0; i<40; i++)
{
if (vards[i] != replaase[h][0][i])
{
break;
}
}
if (i==40)
{
atrada = true;
break;
}
}
if (atrada)
{
for (i=0; i<40,replaase[h][1][i]!=' '; i++)
{
fputc (replaase[h][1][i], pf3);
}
} else {
for (i=0; i<40,vards[i]!=' '; i++)
{
fputc (vards[i], pf3);
}
}
for (i=0; i<40; i++)
{
vards[i] = ' ';
}
burts = 0;
fputc (' ', pf3);
} else {
vards[burts] = c;
burts++;
}
} while (c != EOF);
fclose (pf1);
fclose (pf2);
fclose (pf3);
system ("Pause");
return 0;
}
| |