Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <fstream>
- using namespace std;
- class ReadSp {
- private:
- vector<string> name;
- vector<double> paramA;
- vector<double> paramB;
- public:
- void addName(string nm) {name.push_back(nm);};
- string getName(int ind) {return name[ind];};
- void addParamA(double a) {paramA.push_back(a);};
- double getParamA(int ia) {return paramA[ia];};
- void addParamB(double b) {paramB.push_back(b);};
- double getParamB(int ib) {return paramB[ib];};
- int non() {return name.size();};
- };
- int main () {
- ReadSp sp1;
- string nn;
- double A;
- double B;
- ifstream fin;
- fin.open("sprav.txt");
- while (!fin.eof()) {
- fin >> nn >> A >> B;
- sp1.addName(nn);
- sp1.addParamA(A);
- sp1.addParamB(B);
- }
- fin.close();
- cout << "Загружено элементов: " << sp1.non() << endl;
- cout << "Введите индекс: ";
- int index;
- cin >> index;
- cout << sp1.getName(index) << endl;
- cout << sp1.getParamA(index) << endl;
- cout << sp1.getParamB(index) << endl;
- return 0;
- }
- ***
- файл sprav.txt
- ASDx6 120 12.5
- QWpp4 112 10.5
- ZXp09 100 10
- TTT 123 23
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement