题解 | #计算某字符出现次数#
明明的随机数
http://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
#include<iostream> using namespace std; int main() { int i=0; int N; cin >> N; int arr[N]; for(int i = 0; i< N; i++) { cin >> arr[i]; } for(i=0; i<N; i++) for(int j=i + 1; j<N; j++) { if(arr[j] == 0) { continue; } else if(arr[i] == arr[j]) { arr[j] = 0; } else if(arr[i] > arr[j]) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } for(i=0; i<N; i++) { if(arr[i] != 0) { cout << arr[i] << endl; } } return 0; }