超过时间限制错误.这是什么意思? [英] Time limit exceeded error. what does it mean?
本文介绍了超过时间限制错误.这是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想编写一个C程序,该程序最多打印10个整数.但是我得到这个错误.是什么问题?(错误是:超过了时间限制)
I want to write a C program that prints the maximum of 10 integer numbers. but i get this error. what is the problem?(error is: time limit exceeded)
int main()
{
int arr[9];
int i;
int max=-1;
for(i=0;i<=10;i++) {
scanf("%d",&arr[i]);
if(arr[i]>arr[i+1]){
arr[i]=max;
}
}
printf("%d",max);
}
程序就这样工作,谢谢您的帮助
program works like that,thank u for help
int main()
{
int arr[9];
int i;
int max=-1;
for(i=0;i<=9;i++) {
scanf("%d",&arr[i]);
if(arr[i]>max) {
max=arr[i]; } }
printf("%d",max);
}
推荐答案
您正在索引数组末尾的两个.您需要满足以下条件:
you are indexing two past the end of the array. you need to make the for condition this:
for(i=0;i<9;i++)
这篇关于超过时间限制错误.这是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文