Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Napisz funkcję TablicaNaNapis, która tworzy i zwraca napis utworzony przez znaki z tablicy A od znaku pobranego z pozycji start do znaku z pozycji stop.
- string TablicaNaNapis(const vector<char> & A, int start, int stop);
- Co trzeba założyć o klasie vector i o klasie string, aby zadanie to wykonać w łatwy sposób? (Jakie metody z tych klas są potrzebne?)
- Napisz program testujący opracowaną funkcję.
- */
- #include "stdafx.h"
- #include <queue>
- #include <cstdlib>
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <stack>
- using namespace std;
- string TablicaNaNapis(const vector<char> & A, int start, int stop){
- string wynik = "";
- for(int i = start; i <= stop; i++){
- wynik += A[i];
- }
- return wynik.substr(start, stop);
- }
- int _tmain(int argc, _TCHAR* argv[]){
- vector <char> A(5);
- A[0] = 'a';
- A[1] = 'b';
- A[2] = 'c';
- A[3] = 'd';
- A[4] = 'e';
- string lancuch = TablicaNaNapis(A,0,4);
- cout << lancuch << endl;
- system ("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment