湖上湖
得到的差值个数cin>>R;这是什么意思呢?#include<iostream>#include<iterator>#include<vector>#include<algorithm>using namespace std;int main(){vector<int> v(6,0), diff;cout << "input 6 integers in ascending order: ";for (int i = 0; i < 6; i++) cin >> v[i];for (int i = 0; i < 6; i++)for (int j = 0; j < 6; j++)diff.push_back(abs(v[i] - v[j]));sort(diff.begin(), diff.end());vector<int>::iterator it = unique(diff.begin(), diff.end());diff.resize(it - diff.begin());copy(diff.begin(), diff.end(), ostream_iterator<int>(cout, " "));cout << endl << "Total: " << diff.size() << endl;return 0;}运行一下:input 6 integers in ascending order: 1 2 3 4 5 60 1 2 3 4 5Total: 6input 6 integers in ascending order: 21 54 68 97 123 4120 14 26 29 33 43 47 55 69 76 102 289 315 344 358 391Total: 16