做一个循环,加一个退出按钮,应该就行了
while(true)
{
if(条件合适)
do.......
end do
else
{
break;
}
}
你指的是控制台窗口程序是吧,直接在main函数中加个while(1)循环,把你的代码写到这个循环里就可以了。
别加while(1),加上system("pause");
#include
main()
{
int x,y,sum;
while(1)
{
scanf("%d %d",&x,&y);
sum=x+y;
printf("sum is %d\n",sum);
}
getch();
}