Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<vector>
- #include<windows.h>
- using namespace std;
- void createVec(vector<int>&);
- void showVec(const vector<int>&);
- void multVec(const vector<int>&);
- int main(){
- cout << "ENTER VALUES (-1 to stop): ";
- vector<int> uVec;
- createVec(uVec);
- showVec(uVec);
- cout << "MULTIPLY? (yes or no): ";
- string yOr;
- cin >> yOr;
- if(yOr == "yes"){
- multVec(uVec);
- }else{
- cout << "COMPLETED";
- }
- system("pause");
- return 0;
- }
- void createVec(vector<int>& newVec){
- int uInput;
- cin >> uInput;
- while(uInput != -1){
- newVec.push_back(uInput);
- cin >> uInput;
- }
- }
- void showVec(const vector<int>& newVec){
- cout << "VECTOR: ";
- for(unsigned int i = 0; i < newVec.size(); i++){
- cout << newVec[i] << " ";
- }
- }
- void multVec(const vector<int>& newVec){
- cout << "BY WHAT NUMBER?: ";
- int uInput;
- cin >> uInput;
- for(unsigned int i = 0; i < newVec.size(); i++){
- cout << newVec[i] * uInput << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement