相異なる文の種類の数(c++の場合)
#include <string> #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(void){ vector<string> line; string oneString; while(getline(cin,oneString) ){ if(oneString == "") break; line.push_back(oneString); } sort(line.begin(), line.end(),greater<string>()); int i=0; int chohuku = 0; while(i+1 < line.size()){ if(line[i] == line[i+1]){ chohuku++; } i++; } cout << (line.size()-chohuku) << endl; return 0; }