write a programe that reads number from a file named "data.txt" and tell wheather all number in that file are unique or not ? i
#include <iostream>
#include <fstream>
#include <set>
using namespace std;
int main() {
ifstream ifs("data.txt");
set<int> S;
int x;
while (!ifs.eof()) {
ifs >> x;
auto it = S.find(x);
if (it == S.end()) {
cout << "Not unique";
return 0;
}
}
cout << "All numbers are unique";
return 0;
}
Comments
Leave a comment