VC++程序自动关闭
#defineLENGTH10#includeintmain(){intnumber,counter,index,temp;intlow,up;intarray[LENG...
#define LENGTH 10 #include
int main() { int number,counter,index,temp; int low,up; int array[LENGTH]; printf("\n"); for(counter=0;counter<LENGTH;counter++){ printf("please enter array[%d]:",counter); scanf("%d",&array[counter]); } for(number=1;number<LENGTH;number++){ low=0; up=LENGTH-number; index=low; for(counter=low+1;counter<=up;counter++){ if(array[index]<array[counter]){ index=counter; } } temp=array[index]; array[index]=array[up]; array[up]=temp; } for(counter=0;counter<LENGTH;counter++){ printf("%8d",array[counter]); } } 这个程序运行完了就会自动关闭,求大神解决,win7系统,microsoft visual c++6.0本人新手,暂无奖励,谢谢帮忙 展开
int main() { int number,counter,index,temp; int low,up; int array[LENGTH]; printf("\n"); for(counter=0;counter<LENGTH;counter++){ printf("please enter array[%d]:",counter); scanf("%d",&array[counter]); } for(number=1;number<LENGTH;number++){ low=0; up=LENGTH-number; index=low; for(counter=low+1;counter<=up;counter++){ if(array[index]<array[counter]){ index=counter; } } temp=array[index]; array[index]=array[up]; array[up]=temp; } for(counter=0;counter<LENGTH;counter++){ printf("%8d",array[counter]); } } 这个程序运行完了就会自动关闭,求大神解决,win7系统,microsoft visual c++6.0本人新手,暂无奖励,谢谢帮忙 展开
1个回答
展开全部
在最后一行加system("pause");,像这样:
#define LENGTH 10
#include <iostream>
int main()
{
int number,counter,index,temp;
int low,up;
int array[LENGTH];
printf("\n");
for(counter=0;counter<LENGTH;counter++)
{
printf("please enter array[%d]:",counter);
scanf("%d",&array[counter]);
}
for(number=1;number<LENGTH;number++)
{
low=0;
up=LENGTH-number;
index=low;
for(counter=low+1;counter<=up;counter++)
{
if(array[index]<array[counter])
{
index=counter;
}
}
temp=array[index];
array[index]=array[up];
array[up]=temp;
}
for(counter=0;counter<LENGTH;counter++)
{
printf("%8d",array[counter]);
}
system("pause");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询