I wrote the following in C language.
As long as I run it on hand, it's right, but it's going to be WA...
Is there anything wrong?
There is no difference when I try to differentiate the results by dropping the answers from others and redirecting them to a file locally.
#include<stdio.h>
void trace(intr[], intN){
for(inti=0;i<N;i++){
printf("%d", r[i]);
if(i!=N-1){
printf("";
}
}
printf("\n");
}
int main() {
intr[100];
int N;
scanf("%d", & N);
for(inti=0;i<N;i++){
scanf("%d", &r[i]);
}
trace(r,N);
int j, i, v;
for(i=1;i<N;i++){
v=r[i];
j = i-1;
while(v>=0&r[j]>v){
r[j+1] = r[j];
j--;
}
r[j+1] = v;
trace(r,N);
}
return 0;
}
while(v>=0&r[j]>v){
r[j+1] = r[j];
j--;
}
There are no restrictions on the j
value.Therefore, it appears to be accessing beyond the r
range.Conversely, the value of v
does not change, so it should not be meaningful to evaluate v>=0
per loop.
524 Uncaught (inpromise) Error on Electron: An object could not be cloned
540 Unable to install versioned in Google Colab
543 Understanding How to Configure Google API Key
679 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
543 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.