我做一個c++的題目:10002:Black Box
題目內容:
https://gpe2.acm-icpc.tw//domjudge2/pct/showproblemtab.php?probid=10002&cid=5
我的程式:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int n,m,i=0,d=0,o=0;
int a[0],b[0],c[0];
cin>>m;
cin>>n;
for(int j=0;j<m;j++)
{cin>>a[j];}
for(int j=0;j<n;j++)
{cin>>b[j];}
while(d<m)
{
c[d]=a[d];
if(d>0)
{
for(int j=0;j<=d+1;j++) //做排序
{
for(int k=j;k<=d;k++)
{
if(c[k]<c[j])
{
o=c[k];
c[k]=c[j];
c[j]=o;
}
}
}
}
if(b[i]==d+1)
{
m:
i++;
cout<<c[i-1]<<endl;
if(b[i-1]==b[i]&&b[i]!=NULL)
{
goto m;
}
}
d++;
}
system("PAUSE");
return EXIT_SUCCESS;
}
可是執行卻是run-error
source.cpp: In function 'int main(int, char**)':
source.cpp:41: warning: NULL used in arithmetic
source.cpp:49: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result
不太懂為什麼?
This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers. Five Filters recommends: