求大神,在线等,急急急急!

求数组中最大数的下标:
#include

#include

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {

int a[10],k=0,i;

for(i=0;i<=9;i++)

{

    scanf("%d",&a[i]);

}

for(i=0;i<=9;i++)

{

    if(a[k]<a[i])

    k=i;

}
printf("%d",k);
return 0;
}
为什么得不出正确结果?急急急急,求大神,在线等。

另外,之前的回答,如果解决了,请及时采纳,点下我回答右边的蓝色采纳按钮即可。
之前的回答在 http://ask.csdn.net/my

http://ask.csdn.net/questions/377063

有输出k么
printf("%d",k);

k没有初始化,所以会数组越界

程序没错呀,输出是下标,不是最大的数值