编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#22185 | #1119. Rhodoks的2-sum问题 | Compile Error | 0 | 0 ms | 0 K | C++ / 751 B | paul0917 | 2020-02-11 22:39:44 |
#include <stdio.h>
#include <string.h>
#include <math.h>
int numlist(int a[], int len) {
len = strlen(a);
for (int i = 0; i < len; i++) {
scanf("%d", a);
}
return a;
}
int add(int x[], int y[][]) {
for (int j = 0; j < strlen(x) - 1; j++) {
for (int i = j; i < strlen(x); i++) {
y[j][i] = x[j] + x[i];
}
}
return y;
}
int main() {
long long n, K;
int u = 0;
scanf("%lld %lld", n, K);
int p[500000];
int q[500000][500000];
numlist(p, n);
add(p[500000], q[500000][500000]);
for (int j = 0; j < strlen(p); j++) {
for (int i = 0; i < strlen(p); i++) {
if (q[j][i] == K) {
u++;
break;
}
}
}
if (u != 0)
printf("Yes");
else
printf("No");
return 0;
}
编译信息
/sandbox/1/a.cpp: In function 'int numlist(int*, int)':
/sandbox/1/a.cpp:7:15: error: cannot convert 'int*' to 'const char*'
len = strlen(a);
^
In file included from /sandbox/1/a.cpp:2:
/usr/include/string.h:384:35: note: initializing argument 1 of 'size_t strlen(const char*)'
extern size_t strlen (const char *__s)
~~~~~~~~~~~~^~~
/sandbox/1/a.cpp:12:9: error: invalid conversion from 'int*' to 'int' [-fpermissive]
return a;
^
/sandbox/1/a.cpp: At global scope:
/sandbox/1/a.cpp:15:27: error: declaration of 'y' as multidimensional array must have bounds for all dimensions except the first
int add(int x[], int y[][])
^
/sandbox/1/a.cpp: In function 'int add(...)':
/sandbox/1/a.cpp:17:29: error: 'x' was not declared in this scope
for (int j = 0; j < strlen(x) - 1; j++)
^
/sandbox/1/a.cpp:21:4: error: 'y' was not declared in this scope
y[j][i] = x[j] + x[i];
^
/sandbox/1/a.cpp:24:10: error: 'y' was not declared in this scope
return y;
^
/sandbox/1/a.cpp:24:10: note: suggested alternative: 'yn'
return y;
^
yn
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:32:8: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'long long int' [-Wformat=]
scanf("%lld %lld", n, K);
^~~~~~~~~~~ ~
/sandbox/1/a.cpp:32:8: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'long long int' [-Wformat=]
/sandbox/1/a.cpp:34:22: error: size of array 'q' is too large
int q[500000][500000];
^
/sandbox/1/a.cpp:36:17: error: 'q' was not declared in this scope
add(p[500000], q[500000][500000]);
^
/sandbox/1/a.cpp:37:29: error: cannot convert 'int*' to 'const char*'
for (int j = 0; j < strlen(p) ; j++)
^
In file included from /sandbox/1/a.cpp:2:
/usr/include/string.h:384:35: note: initializing argument 1 of 'size_t strlen(const char*)'
extern size_t strlen (const char *__s)
~~~~~~~~~~~~^~~
/sandbox/1/a.cpp:39:30: error: cannot convert 'int*' to 'const char*'
for (int i = 0; i < strlen(p); i++)
^
In file included from /sandbox/1/a.cpp:2:
/usr/include/string.h:384:35: note: initializing argument 1 of 'size_t strlen(const char*)'
extern size_t strlen (const char *__s)
~~~~~~~~~~~~^~~
/sandbox/1/a.cpp: In function 'int numlist(int*, int)':
/sandbox/1/a.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", a);
~~~~~^~~~~~~~~
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld", n, K);
~~~~~^~~~~~~~~~~~~~~~~~~