Language: C++





#include<iostream>
#include<sstream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;




int main()
{
&#160; int n;
&#160; string s;
&#160; char k;
&#160; while(cin>>n,n){
&#160; &#160; map<string,int>used;
&#160; &#160; for(int i=0;i<n;i++){
&#160; &#160; &#160; cin.ignore();
&#160; &#160; &#160; getline(cin,s);
&#160; &#160; &#160; stringstream ss(s);
&#160; &#160; &#160; string word;
&#160; &#160; &#160; while(ss>>word){
&#160; &#160; &#160; &#160; if(used.find(word)==used.end())used.insert(make_pair(word,1));
&#160; &#160; &#160; &#160; else used[word]++;
&#160; &#160; &#160; }
&#160; &#160; }
&#160; &#160; cin>>k;
&#160; &#160; map<string,int>::iterator it;
&#160; &#160; vector<string>v;
&#160; &#160; for(it=used.begin();it!=used.end();it++){
&#160; &#160; &#160; if(it->first[0]!=k)continue;
&#160; &#160; &#160; v.push_back(it->first);
&#160; &#160; }
&#160; &#160; sort(v.begin(),v.end());
&#160; &#160; if(v.empty()){
&#160; &#160; &#160; puts("NA");
&#160; &#160; }else{
&#160; &#160; &#160; int cnt=0;
&#160; &#160; &#160; for(int i=0;i<v.size();i++){
&#160; &#160; &#160; &#160; if(++cnt>5)break;
&#160; &#160; &#160; &#160; if(i!=0)cout<<" ";
&#160; &#160; &#160; &#160; cout<<v[i];
&#160; &#160; &#160; }
&#160; &#160; &#160; cout<<endl;
&#160; &#160; }
&#160; }
}

Compiler output:
a.cc:17:2: error: stray '#' in program
   17 | &#160; int n;
      |  ^
a.cc:18:2: error: stray '#' in program
   18 | &#160; string s;
      |  ^
a.cc:19:2: error: stray '#' in program
   19 | &#160; char k;
      |  ^
a.cc:20:2: error: stray '#' in program
   20 | &#160; while(cin>>n,n){
      |  ^
a.cc:21:2: error: stray '#' in program
   21 | &#160; &#160; map<string,int>used;
      |  ^
a.cc:21:9: error: stray '#' in program
   21 | &#160; &#160; map<string,int>used;
      |         ^
a.cc:22:2: error: stray '#' in program
   22 | &#160; &#160; for(int i=0;i<n;i++){
      |  ^
a.cc:22:9: error: stray '#' in program
   22 | &#160; &#160; for(int i=0;i<n;i++){
      |         ^
a.cc:23:2: error: stray '#' in program
   23 | &#160; &#160; &#160; cin.ignore();
      |  ^
a.cc:23:9: error: stray '#' in program
   23 | &#160; &#160; &#160; cin.ignore();
      |         ^
a.cc:23:16: error: stray '#' in program
   23 | &#160; &#160; &#160; cin.ignore();
      |                ^
a.cc:24:2: error: stray '#' in program
   24 | &#160; &#160; &#160; getline(cin,s);
      |  ^
a.cc:24:9: error: stray '#' in program
   24 | &#160; &#160; &#160; getline(cin,s);
      |         ^
a.cc:24:16: error: stray '#' in program
   24 | &#160; &#160; &#160; getline(cin,s);
      |                ^
a.cc:25:2: error: stray '#' in program
   25 | &#160; &#160; &#160; stringstream ss(s);
      |  ^
a.cc:25:9: error: stray '#' in program
   25 | &#160; &#160; &#160; stringstream ss(s);
      |         ^
a.cc:25:16: error: stray '#' in program
   25 | &#160; &#160; &#160; stringstream ss(s);
      |                ^
a.cc:26:2: error: stray '#' in program
   26 | &#160; &#160; &#160; string word;
      |  ^
a.cc:26:9: error: stray '#' in program
   26 | &#160; &#160; &#160; string word;
      |         ^
a.cc:26:16: error: stray '#' in program
   26 | &#160; &#160; &#160; string word;
      |                ^
a.cc:27:2: error: stray '#' in program
   27 | &#160; &#160; &#160; while(ss>>word){
      |  ^
a.cc:27:9: error: stray '#' in program
   27 | &#160; &#160; &#160; while(ss>>word){
      |         ^
a.cc:27:16: error: stray '#' in program
   27 | &#160; &#160; &#160; while(ss>>word){
      |                ^
a.cc:28:2: error: stray '#' in program
   28 | &#160; &#160; &#160; &#160; if(used.find(word)==used.end())used.insert(make_pair(word,1));
      |  ^
a.cc:28:9: error: stray '#' in program
   28 | &#160; &#160; &#160; &#160; if(used.find(word)==used.end())used.insert(make_pair(word,1));
      |         ^
a.cc:28:16: error: stray '#' in program
   28 | &#160; &#160; &#160; &#160; if(used.find(word)==used.end())used.insert(make_pair(word,1));
      |                ^
a.cc:28:23: error: stray '#' in program
   28 | &#160; &#160; &#160; &#160; if(used.find(word)==used.end())used.insert(make_pair(word,1));
      |                       ^
a.cc:29:2: error: stray '#' in program
   29 | &#160; &#160; &#160; &#160; else used[word]++;
      |  ^
a.cc:29:9: error: stray '#' in program
   29 | &#160; &#160; &#160; &#160; else used[word]++;
      |         ^
a.cc:29:16: error: stray '#' in program
   29 | &#160; &#160; &#160; &#160; else used[word]++;
      |                ^
a.cc:29:23: error: stray '#' in program
   29 | &#160; &#160; &#160; &#160; else used[word]++;
      |                       ^
a.cc:30:2: error: stray '#' in program
   30 | &#160; &#160; &#160; }
      |  ^
a.cc:30:9: error: stray '#' in program
   30 | &#160; &#160; &#160; }
      |         ^
a.cc:30:16: error: stray '#' in program
   30 | &#160; &#160; &#160; }
      |                ^
a.cc:31:2: error: stray '#' in program
   31 | &#160; &#160; }
      |  ^
a.cc:31:9: error: stray '#' in program
   31 | &#160; &#160; }
      |         ^
a.cc:32:2: error: stray '#' in program
   32 | &#160; &#160; cin>>k;
      |  ^
a.cc:32:9: error: stray '#' in program
   32 | &#160; &#160; cin>>k;
      |         ^
a.cc:33:2: error: stray '#' in program
   33 | &#160; &#160; map<string,int>::iterator it;
      |  ^
a.cc:33:9: error: stray '#' in program
   33 | &#160; &#160; map<string,int>::iterator it;
      |         ^
a.cc:34:2: error: stray '#' in program
   34 | &#160; &#160; vector<string>v;
      |  ^
a.cc:34:9: error: stray '#' in program
   34 | &#160; &#160; vector<string>v;
      |         ^
a.cc:35:2: error: stray '#' in program
   35 | &#160; &#160; for(it=used.begin();it!=used.end();it++){
      |  ^
a.cc:35:9: error: stray '#' in program
   35 | &#160; &#160; for(it=used.begin();it!=used.end();it++){
      |         ^
a.cc:36:2: error: stray '#' in program
   36 | &#160; &#160; &#160; if(it->first[0]!=k)continue;
      |  ^
a.cc:36:9: error: stray '#' in program
   36 | &#160; &#160; &#160; if(it->first[0]!=k)continue;
      |         ^
a.cc:36:16: error: stray '#' in program
   36 | &#160; &#160; &#160; if(it->first[0]!=k)continue;
      |                ^
a.cc:37:2: error: stray '#' in program
   37 | &#160; &#160; &#160; v.push_back(it->first);
      |  ^
a.cc:37:9: error: stray '#' in program
   37 | &#160; &#160; &#160; v.push_back(it->first);
      |         ^
a.cc:37:16: error: stray '#' in program
   37 | &#160; &#160; &#160; v.push_back(it->first);
      |                ^
a.cc:38:2: error: stray '#' in program
   38 | &#160; &#160; }
      |  ^
a.cc:38:9: error: stray '#' in program
   38 | &#160; &#160; }
      |         ^
a.cc:39:2: error: stray '#' in program
   39 | &#160; &#160; sort(v.begin(),v.end());
      |  ^
a.cc:39:9: error: stray '#' in program
   39 | &#160; &#160; sort(v.begin(),v.end());
      |         ^
a.cc:40:2: error: stray '#' in program
   40 | &#160; &#160; if(v.empty()){
      |  ^
a.cc:40:9: error: stray '#' in program
   40 | &#160; &#160; if(v.empty()){
      |         ^
a.cc:41:2: error: stray '#' in program
   41 | &#160; &#160; &#160; puts("NA");
      |  ^
a.cc:41:9: error: stray '#' in program
   41 | &#160; &#160; &#160; puts("NA");
      |         ^
a.cc:41:16: error: stray '#' in program
   41 | &#160; &#160; &#160; puts("NA");
      |                ^
a.cc:42:2: error: stray '#' in program
   42 | &#160; &#160; }else{
      |  ^
a.cc:42:9: error: stray '#' in program
   42 | &#160; &#160; }else{
      |         ^
a.cc:43:2: error: stray '#' in program
   43 | &#160; &#160; &#160; int cnt=0;
      |  ^
a.cc:43:9: error: stray '#' in program
   43 | &#160; &#160; &#160; int cnt=0;
      |         ^
a.cc:43:16: error: stray '#' in program
   43 | &#160; &#160; &#160; int cnt=0;
      |                ^
a.cc:44:2: error: stray '#' in program
   44 | &#160; &#160; &#160; for(int i=0;i<v.size();i++){
      |  ^
a.cc:44:9: error: stray '#' in program
   44 | &#160; &#160; &#160; for(int i=0;i<v.size();i++){
      |         ^
a.cc:44:16: error: stray '#' in program
   44 | &#160; &#160; &#160; for(int i=0;i<v.size();i++){
      |                ^
a.cc:45:2: error: stray '#' in program
   45 | &#160; &#160; &#160; &#160; if(++cnt>5)break;
      |  ^
a.cc:45:9: error: stray '#' in program
   45 | &#160; &#160; &#160; &#160; if(++cnt>5)break;
      |         ^
a.cc:45:16: error: stray '#' in program
   45 | &#160; &#160; &#160; &#160; if(++cnt>5)break;
      |                ^
a.cc:45:23: error: stray '#' in program
   45 | &#160; &#160; &#160; &#160; if(++cnt>5)break;
      |                       ^
a.cc:46:2: error: stray '#' in program
   46 | &#160; &#160; &#160; &#160; if(i!=0)cout<<" ";
      |  ^
a.cc:46:9: error: stray '#' in program
   46 | &#160; &#160; &#160; &#160; if(i!=0)cout<<" ";
      |         ^
a.cc:46:16: error: stray '#' in program
   46 | &#160; &#160; &#160; &#160; if(i!=0)cout<<" ";
      |                ^
a.cc:46:23: error: stray '#' in program
   46 | &#160; &#160; &#160; &#160; if(i!=0)cout<<" ";
      |                       ^
a.cc:47:2: error: stray '#' in program
   47 | &#160; &#160; &#160; &#160; cout<<v[i];
      |  ^
a.cc:47:9: error: stray '#' in program
   47 | &#160; &#160; &#160; &#160; cout<<v[i];
      |         ^
a.cc:47:16: error: stray '#' in program
   47 | &#160; &#160; &#160; &#160; cout<<v[i];
      |                ^
a.cc:47:23: error: stray '#' in program
   47 | &#160; &#160; &#160; &#160; cout<<v[i];
      |                       ^
a.cc:48:2: error: stray '#' in program
   48 | &#160; &#160; &#160; }
      |  ^
a.cc:48:9: error: stray '#' in program
   48 | &#160; &#160; &#160; }
      |         ^
a.cc:48:16: error: stray '#' in program
   48 | &#160; &#160; &#160; }
      |                ^
a.cc:49:2: error: stray '#' in program
   49 | &#160; &#160; &#160; cout<<endl;
      |  ^
a.cc:49:9: error: stray '#' in program
   49 | &#160; &#160; &#160; cout<<endl;
      |         ^
a.cc:49:16: error: stray '#' in program
   49 | &#160; &#160; &#160; cout<<endl;
      |                ^
a.cc:50:2: error: stray '#' in program
   50 | &#160; &#160; }
      |  ^
a.cc:50:9: error: stray '#' in program
   50 | &#160; &#160; }
      |         ^
a.cc:51:2: error: stray '#' in program
   51 | &#160; }
      |  ^
a.cc: In function 'int main()':
a.cc:17:3: error: lvalue required as unary '&' operand
   17 | &#160; int n;
      |   ^~~
a.cc:18:3: error: lvalue required as unary '&' operand
   18 | &#160; string s;
      |   ^~~
a.cc:19:3: error: lvalue required as unary '&' operand
   19 | &#160; char k;
      |   ^~~
a.cc:20:3: error: lvalue required as unary '&' operand
   20 | &#160; while(cin>>n,n){
      |   ^~~
a.cc:21:3: error: lvalue required as unary '&' operand
   21 | &#160; &#160; map<string,int>used;
      |   ^~~
a.cc:21:10: error: lvalue required as unary '&' operand
   21 | &#160; &#160; map<string,int>used;
      |          ^~~
a.cc:22:3: error: lvalue required as unary '&' operand
   22 | &#160; &#160; for(int i=0;i<n;i++){
      |   ^~~
a.cc:22:10: error: lvalue required as unary '&' operand
   22 | &#160; &#160; for(int i=0;i<n;i++){
      |          ^~~
a.cc:23:3: error: lvalue required as unary '&' operand
   23 | &#160; &#160; &#160; cin.ignore();
      |   ^~~
a.cc:23:10: error: lvalue required as unary '&' operand
   23 | &#160; &#160; &#160; cin.ignore();
      |          ^~~
a.cc:23:17: error: lvalue required as unary '&' operand
   23 | &#160; &#160; &#160; cin.ignore();
      |                 ^~~
a.cc: