add
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define SIZE 10
|
||||
|
||||
int main() {
|
||||
int arr[SIZE] = {2, 5, 3, 5, 1, 2, 6, 7, 8, 9};
|
||||
bool used[SIZE] = {false}; // 用于标记数字是否已被使用
|
||||
|
||||
for (int i = 0; i < SIZE; ++i) {
|
||||
if (!used[arr[i]]) { // 检查当前值是否已被使用
|
||||
printf("First occurrence of %d\n", arr[i]);
|
||||
used[arr[i]] = true; // 标记该值为已使用
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user