回复 8楼 TonyDeng
我会好好的思考你这句话的
[此贴子已经被作者于2015-12-6 09:51编辑过]
程序代码:
/*
http://bbs.bccn.net/thread-459912-1-1.html
Version 1, 2015.12.06.
*/
#include <stdio.h>
#include <conio.h>
int main(void)
{
int iDay;
int iScanReturn;
int bContinue;
char cBuffer[1024];
do
{
bContinue = 0;
printf_s("please input a number: ");
iScanReturn = scanf_s("%d", &iDay);
if (iScanReturn != 1)
{
gets_s(cBuffer);
bContinue = 1;
}
switch (iDay)
{
case 1:
case 2:
case 3:
case 4:
break;
case 5:
printf_s("Today to work hark\n");
break;
case 6:
printf_s("Today stay at home to sleep\n");
break;
case 7:
printf_s("Go shopping with friends\n");
break;
default:
printf_s("Error\n");
bContinue = 1;
break;
}
} while (bContinue);
_getch();
return 0;
}

程序代码:
/*
http://bbs.bccn.net/thread-459912-1-1.html
Version 2, 2015.12.06.
*/
#include <stdio.h>
#include <conio.h>
int main(void)
{
int iDay;
int iScanReturn;
int bContinue = 1;
char cBuffer[1024];
while (bContinue)
{
bContinue = 0;
printf_s("please input a number: ");
iScanReturn = scanf_s("%d", &iDay);
if (iScanReturn != 1)
{
gets_s(cBuffer);
bContinue = 1;
}
switch (iDay)
{
case 1:
case 2:
case 3:
case 4:
break;
case 5:
printf_s("Today to work hark\n");
break;
case 6:
printf_s("Today stay at home to sleep\n");
break;
case 7:
printf_s("Go shopping with friends\n");
break;
default:
printf_s("Error\n");
bContinue = 1;
break;
}
}
_getch();
return 0;
}

程序代码:
/*
http://bbs.bccn.net/thread-459912-1-1.html
Version 3, 2015.12.06.
*/
#include <stdio.h>
#include <conio.h>
const char* Schedule[] = {
"",
"",
"",
"",
"Today to work hark",
"Today stay at home to sleep",
"Go shopping with friends"
};
int main(void)
{
int iDay;
int iScanReturn;
int bContinue;
char cBuffer[1024];
do
{
printf_s("please input a number: ");
iScanReturn = scanf_s("%d", &iDay);
if ((iScanReturn == 1) && (iDay >= 1) && (iDay <= 7))
{
printf_s("%s\n", Schedule[iDay - 1]);
bContinue = 0;
}
else
{
gets_s(cBuffer);
printf_s("Error\n");
bContinue = 1;
}
} while (bContinue);
printf_s("\nPress any key to continue...");
_getch();
return 0;
}

程序代码:
/*
http://bbs.bccn.net/thread-459912-1-1.html
Version 4, 2015.12.06.
*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
const char* Schedule[] = {
"",
"",
"",
"",
"Today to work hark",
"Today stay at home to sleep",
"Go shopping with friends"
};
int main(void)
{
int iDay;
int iScanReturn;
int bContinue;
char cBuffer[1024];
do
{
printf_s("please input a number: ");
iScanReturn = scanf_s("%d", &iDay);
if ((iScanReturn == 1) && (iDay >= 1) && (iDay <= _countof(Schedule)))
{
printf_s("%s\n", Schedule[iDay - 1]);
bContinue = 0;
}
else
{
gets_s(cBuffer);
printf_s("Error\n");
bContinue = 1;
}
} while (bContinue);
printf_s("\nPress any key to continue...");
_getch();
return EXIT_SUCCESS;
}
