如何给这个时钟加减的程序加上一个循环选择继续执行还是结束?
#include<stdio.h>main()
{
int h1, min1, sec1, a;
int h2, min2, sec2, b;
char choice;
printf("A for add\n");
printf("S for subtract\n");
printf("Please enter A or S only:");
scanf("%c", &choice);
switch (choice)
{
case 'A': printf("\nPlease enter the first clock in correct Military format:\n");
scanf("%d%d%d", &h1, &min1, &sec1);
printf("Clock1=%d seconds\n", a=h1*3600+min1*60+sec1);
printf("\nPlease enter the second clock in correct Military format:\n");
scanf("%d%d%d", &h2, &min2, &sec2);
printf("Clock2=%d seconds\n", b=h2*3600+min2*60+sec2);
if (a+b==86400)
{
printf("\nThen Clock3 is 00:00:00\n");
}
else
{
if (a+b>86400)
{
printf("\nThen Clock3 is %d:%d:%d hrs\n", (a+b)/3600-24, (a+b)%3600/60, (a+b)%60);
}
else
{
printf("\nThen Clock3 is %d:%d:%d hrs\n", (a+b)/3600, (a+b)%3600/60, (a+b)%60);
}
}
break;
case 'S': printf("\nPlease enter the first clock in correct Military format:\n");
scanf("%d%d%d", &h1, &min1, &sec1);
printf("Clock1=%d seconds\n", a=h1*3600+min1*60+sec1);
printf("\nPlease enter the second clock in correct Military format:\n");
scanf("%d%d%d", &h2, &min2, &sec2);
printf("Clock2=%d seconds\n", b=h2*3600+min2*60+sec2);
if (a-b==0)
{
printf("\nThen Clock3 is 00:00:00\n");
}
else
if (a-b<0)
{
printf("\nThen Clock3 is %d:%d:%dhrs\n", ( a+24*3600-b)/3600, (a+24*3600-b)%3600/60, (a+24*3600-b)%60);
}
else
{
printf("\nThen Clock3 is %d:%d:%dhrs\n", ( a-b)/3600, (a-b)%3600/60, (a-b)%60);
}
break;
default: printf("\nInvalid choice, please try again.\n\n");
}
}