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
|
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
const char CDfv1[]="data1.txt"; // this is where 'Arklys' is placed
const char CDfv2[]="data2.txt"; // this is where 'Atvykstama' is placed
const char CRfv[]="results.txt";
const int CMax = 250;
void ReadingFromFile(const char CDfv, char A, int & n);
void Decode( char A, char B, int n, int m, int & code);
void Printing(const char CRfv, char A, int n, int code);
int main()
{
char A[CMax]; int n;
char B[CMax]; int m;
int code;
ReadingFromFile(CDfv1, A, n);
ReadingFromFile(CDfv2, B, m);
Decode(A, B, n, m, code);
ofstream fr(CRfv);
fr.close();
Printing(CRfv, A, n, code);
Printing(CRfv, B, m, code);
fr.close();
return 0;
}
void ReadingFromFile(const char CDfv, char A, int & n)
{
char s;
n=0;
ifstream fd(CDfv);
while(!fd.eof()){
fd.get(s);
A[n]=tolower(s);
n++;
}
}
void Decoding( char A, char B, int n, int m, int & code)
{
kodas = 0;
while(A[n]<B[m]){
if(A[n]==B[m]){
code++;
}
}
}
void Printing(const char CRfv, char A, int n, int code)
{
ofstream fr(CRfv, ios::app);
fr << code;
}
|