|
发表于 2023-10-24 23:48:50
|
显示全部楼层
- #include<bits/stdc++.h>
- using namespace std;
- int n, book[1009], x, i, c = 0;
- int main() {
- // Input the value of n
- cin >> n;
-
- // Loop to input the values and mark them in the book array
- for(i = 1; i <= n; i++) {
- cin >> x;
- book[x] = 1;
- }
-
- // Count the number of marked values in the book array
- for(x = 1; x <= 1000; x++) {
- if(book[x] == 1) {
- c++;
- }
- }
-
- // Output the count of marked values
- cout << c;
- }
复制代码
This code reads a value n and then reads n more values. It marks each value in the book array. Then, it counts the number of marked values in the book array and outputs the count.
请注意,本回答来自GPT-4
如果问题已经解决,请设置最佳答案 |
|