#include "stdlib.h"//包含random函数的声明#include <vector>#include <fstream>#include <iostream>using namespace std;void stat_diff(vector<int>& array, int *c){ int i; for (i = 0;i<array.size();++i)c[i] = 0;//初始化统计结果为0 for (i = 0;i<array.size();++i)c[array[i]]++;//统计array[i]值的个数}int main(){ vector<int> data; ifstream in("e://data.txt"); if (!in) { cout << "file error!" << endl; exit(1); } int temp; while (!in.eof()) { in >> temp; data.push_back(temp); } in.close(); int c[65536] = { 0 }; stat_diff(data, c); int k = 0; for (int i = 0;i<65536;++i)//统计0~65535之间不同值的个数 if (c[i] != 0)k++; cout << k << endl; return 0;}
新闻热点
疑难解答