编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#22186 | #1119. Rhodoks的2-sum问题 | Compile Error | 0 | 0 ms | 0 K | C++ / 636 B | paul0917 | 2020-02-11 22:41:09 |
#include <stdio.h>
#include <string.h>
#include <math.h>
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];
gets(p);
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:6: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:8:29: error: 'x' was not declared in this scope
for (int j = 0; j < strlen(x) - 1; j++)
^
/sandbox/1/a.cpp:12:4: error: 'y' was not declared in this scope
y[j][i] = x[j] + x[i];
^
/sandbox/1/a.cpp:15:10: error: 'y' was not declared in this scope
return y;
^
/sandbox/1/a.cpp:15:10: note: suggested alternative: 'yn'
return y;
^
yn
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:23: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:23:8: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'long long int' [-Wformat=]
/sandbox/1/a.cpp:25:8: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
gets(p);
^
In file included from /usr/include/stdio.h:862,
from /sandbox/1/a.cpp:1:
/usr/include/bits/stdio2.h:232:1: note: declared here
gets (char *__str)
^~~~
/sandbox/1/a.cpp:25:8: warning: 'char* gets(char*)' is deprecated [-Wdeprecated-declarations]
gets(p);
^
In file included from /usr/include/stdio.h:862,
from /sandbox/1/a.cpp:1:
/usr/include/bits/stdio2.h:232:1: note: declared here
gets (char *__str)
^~~~
/sandbox/1/a.cpp:25:7: error: cannot convert 'int*' to 'char*'
gets(p);
^
In file included from /usr/include/stdio.h:862,
from /sandbox/1/a.cpp:1:
/usr/include/bits/stdio2.h:232:13: note: initializing argument 1 of 'char* gets(char*)'
gets (char *__str)
~~~~~~^~~~~
/sandbox/1/a.cpp:26:22: error: size of array 'q' is too large
int q[500000][500000];
^
/sandbox/1/a.cpp:27:2: error: 'numlist' was not declared in this scope
numlist(p, n);
^~~~~~~
/sandbox/1/a.cpp:27:2: note: suggested alternative: 'va_list'
numlist(p, n);
^~~~~~~
va_list
/sandbox/1/a.cpp:28:17: error: 'q' was not declared in this scope
add(p[500000], q[500000][500000]);
^
/sandbox/1/a.cpp:29: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:31: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:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld", n, K);
~~~~~^~~~~~~~~~~~~~~~~~~