编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#22247 | #1119. Rhodoks的2-sum问题 | Compile Error | 0 | 0 ms | 0 K | C++ / 667 B | 电类937权冬瑞 | 2020-02-12 9:36:03 |
#include <stdio.h>
#include <vector>
int main() {
bool result = false;
long int n, k;
scanf("%ld,%ld", &n, &k);
std::vector<long int> a(n);
std::vector<long int>::iterator p = a.begin();
for (long int i = 0; i < n; i++) {
scanf("%ld", (p + i));
}
if (n == 1) {
printf("No");
} else {
for (long int i = 0; i < n - 1; i++) {
for (long int j = i + 1; j < n; j++) {
if (*(p + i) + *(p + j) == k) {
printf("Yes");
return 0;
}
}
}
printf("No")
}
return 0;
}
编译信息
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:10:19: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' [-Wformat=]
scanf("%ld", (p + i));
^~~~~ ~~~~~~~
/sandbox/1/a.cpp:23:21: error: expected ';' before '}' token
printf("No")
^
;
}
~
/sandbox/1/a.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%ld,%ld", &n, &k);
~~~~~^~~~~~~~~~~~~~~~~~~
/sandbox/1/a.cpp:10:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%ld", (p + i));
~~~~~^~~~~~~~~~~~~~~~