Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <string.h>
- using namespace std;
- const char fileData[] = "Duomenys.txt";
- const char fileResult[] = "Rezultatai.txt";
- void read(const char fileData[], string &carFind, string carMap[], string model[], int &n)
- {
- ifstream in(fileData);
- char ch[30];
- char chh[30];
- string temp;
- in.get(ch, 11);
- carFind = ch;
- in >> n;
- if (carFind.length() <= 10)
- {
- for (int i = 0; i < n; i++)
- {
- in.ignore();
- in.get(ch, 11);
- carMap[i] = ch;
- in.get(chh, 26);
- model[i] = chh;
- if (model[i].length() > 25)
- {
- cout << "Ivedete per daug simboliu! " << i + 1 << " eiluteje.";
- }
- }
- }
- else
- {
- cout << "Per ilgas ivestas modelis";
- }
- in.close();
- }
- void print(const char fileOutput[], string carFind, string carMap[], string model[], int n)
- {
- ofstream out(fileOutput);
- for (int i = 0; i < n; i++)
- {
- if (carFind == carMap[i])
- {
- out << carMap[i] << model[i] << endl;
- }
- }
- }
- int main()
- {
- int n;
- string carFind, carMap[30], model[30];
- read(fileData, carFind, carMap, model, n);
- print(fileResult, carFind, carMap, model, n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement