输入字符型数组多个,最后要求用#号结束
char s[100];while (cin>>s……)
输入多个字符型数组,最后用#号结束程序,后面要怎么写。。。。
程序代码:#include<iostream>
#include<string>
using namespace std;
int main(void)
{
string s[100];
int i=0;
while(1)
{
getline(cin,s[i]);
if(s[i]=="#") break;
i++;
}
cout<<"以下是您所输入的字符串:"<<endl;
for(i=0;i<5;i++) cout<<s[i]<<endl;
return 0;
}

程序代码:
// g++ -Wall -march=corei7-avx -Ofast -msse4.2 -mavx -std=c++11 a.cpp -lm -o a
#include <iostream>
#include <vector>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::string;
int main(void)
{
vector<string> vec_str;
string tmp("");
while (cin >> tmp && tmp != "#")
{
vec_str.push_back(tmp);
}
for (vector<string>::iterator i = vec_str.begin(); i != vec_str.end(); ++i)
{
cout << *i << endl;
}
return 0;
}