#include <iostream>
#include<vector>
using namespace std;
void arrayFloatOutput(const vector<float>&a){
for(int i=0;i<a.size();i++)
cout<<a[i]<<" ";
}
void arrayFloatInput(vector<float>&a){
float x;
while (cin>>x){
a.push_back(x);
}
}
void main(){
vector<float>a;
cout<<"Input an array,press Ctrl X then Enter to stop:"<<endl;
arrayFloatInput(a);
cout<<"Element(s) in the array:";
arrayFloatOutput(a);
cout<<endl;
}
Cho mình hỏi với đoạn code trên thì :
- Cách dùng lệnh
while (cin>>x)
như thế mình không hiểu ? - Cái
void arrayFloatOutput(const vector<float>&a)
thì const có tác dụng gì và nếu bỏ nó thì sẽ ra sao ?
Cảm ơn các bạn.!