题目.
#include#include #include #include
#include #include using namespace std; int main() { string A; cin >> A; set s; for (int i = 0; i < A.size(); ++i) s.insert(A[i]); set ::iterator it = s.begin(); int site = s.size(); vector arr(site); vector index(A.size()); //cout << arr[3]; while (it != s.end()) { site--; arr[site] = *it; for (int i = 0; i < A.size(); ++i) if (A[i] == *it) index[i] = site; it++; } cout << "int[] arr = new int[]{"; for (int i = 0; i < s.size(); ++i) { if (i) cout << ','; cout << arr[i]; } cout << "};" << endl << "int[] index = new int[]{"; for (int i = 0; i < A.size(); ++i) { if (i) cout << ','; cout << index[i]; } cout << "};"; return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)