Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- #include <iostream>
- #include <string>
- using namespace std;
- struct TS{
- string str;
- double w;
- char ch;
- };
- void zadachaEdno(TS &object,string criteria) {
- string firstCut = object.str.substr(0,criteria.length());
- string lastCut = object.str.substr(object.str.length()-criteria.length());
- if (firstCut.compare(criteria)==0 && lastCut.compare(criteria)==0) {
- string newStr;
- double newW;
- int firstChar;
- do {
- cout << "Vuvedi new Str:" << endl;
- cin >> newStr;
- cout << "Vuvedi new W:" << endl;
- cin >> newW;
- firstChar = newStr.find_first_of(object.ch);
- } while (newW<object.w || firstChar ==string::npos || newStr.find_first_of(object.ch,firstChar)==string::npos );
- object.str = newStr;
- object.w = newW;
- }
- }
- int main()
- {
- TS object = { "rileri",15,'a' };
- string criteria;
- cout << "Enter criteria:" << endl;
- cin >> criteria;
- zadachaEdno(object,criteria);
- cout << object.str << " " << object.w << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement