- 分享
- 0
- 人气
- 0
- 主题
- 7
- 帖子
- 4707
- UID
- 82675
- 积分
- 5108
- 阅读权限
- 22
- 注册时间
- 2007-6-18
- 最后登录
- 2021-7-27
- 在线时间
- 5767 小时
|
原帖由 shetaikeng 于 2009-8-1 01:27 PM 发表
我想问
如何在 VOID FUNCTION 里面 跑另外一个VOID FUNCTION
我把它连接在一起时就无法运行
但是分开却可以运行
不知道哪里出错了
请帮帮我吧!!!
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
#include <time.h>
#define ESC 27
#define u 117
#define d 100
void introPage();
void selectionMenu();
void ShiftCipherDecipher();
void VigenereCipherDecipher();
void keyCodeGen();
void RotateandStopattheNumber();
void StartStopNumberRotation();
void NumberUpDownRotation();
void ChangeUpDownRotationSpeed();
void lowerToUpper();
void lowerToTitle();
void end();
void UPP();
void DOWN();
int ChangeTime(int);
int main()
{
introPage();
system("pause");
selectionMenu();
return 0;
}
void introPage()
{
printf("\t\tCP1 Miniproject Part 2 <2009 S1>\n");
printf("\t\t================================\n\n");
printf("\t\tModule Group : AA\n\n");
printf("\t\tTask & Members : \n\n");
printf("\t\t1. Rotate and Stop at the Number <40 marks>\n");
printf("\t\t2. Start/Stop Number Rotation <45 marks>\n");
printf("\t\t3. Number Up/Down Rotation <50 marks>\n");
printf("\t\t4. Change Up/Down Rotation Speed <55 marks>\n");
}
void selectionMenu()
{
char choice,response='y';
while(response=='y')
{
system("cls");
printf("\tOperation Menu\n");
printf("\t==============\n\n");
printf("\t1. Rotate and Stop at the Number - \n");
printf("\t2. Start/Stop Number Rotation - \n");
printf("\t3. Number Up/Down Rotation - \n");
printf("\t4. Change Up/Down Rotation Speed - \n");
printf("\t5. Exit Program\n\n");
printf("\tPlease enter your choice: ");
//scanf("%d",&choice);
choice=getch();
if(choice=='1')
{
//RotateandStopattheNumber();
}else if(choice=='2')
{
//StartStopNumberRotation();
}else if(choice=='3')
{
//NumberUpDownRotation();
}else if(choice=='4')
{
ChangeUpDownRotationSpeed();
}else if(choice=='5')
{
printf("\t\tEnd of Program ^ ^\n");
}
printf("\tTry Again? \n");
response=getch();
}
}
void ChangeUpDownRotationSpeed()
{
int numArray[]={1,2,3,4,5,6,7,8,9,10};
int time=1;
char key;
int index;
int temp;
do
{
system("cls");
//display the outlook
printf("\tUp/Down Number Rotation Speed\n");
printf("\t=========================\n\n");
printf("\tEnter [U] for up rotation\n");
printf("\tEnter [D] for down rotation\n");
printf("\tTo stop rotation, any key except [U],[D],[ESC]\n\tPress ESC to quit at anytime.\n\n");
printf("\tHit any key to start\n\n\t");
key=getch();
do
{
for (index=0; index<10; index++)//rotate
{
printf("%02d ",numArray[index]);
_sleep(time*100);
}
printf("\tTime=0.%ds -STOP KEY\n\t\a",time);
if(kbhit())
{
key=getch();
while(key!=ESC)
{
switch(key)
{
case'u':UPP();break;
case'd'OWN();break;
case'1':ChangeTime(1);break;
case'2':ChangeTime(2);break;
case'3':ChangeTime(3);break;
case'4':ChangeTime(4);break;
case'6':ChangeTime(6);break;
case'7':ChangeTime(7);break;
case'8':ChangeTime(8);break;
case'9':ChangeTime(9);break;
}
if(key!=u && key!=d)//if neither "u" nor "d" is hit
{
break;//breaky the while loop to go back to STOP KEY mode
}
}
}//end of kbhit()
}while(key != ESC );//end of the rotation
printf("Try again?");
key=getch();
}while(key!='n');//end of do-while loop
printf("\n");
system("pause");
return 0;
}
void UPP() {
while(key==u && key!=ESC && key!=d)
{
/* using for-loop to shift all 10 elements in one go */ for(index=0; index<9; index++)
{
temp = numArray[index+1]; // moving the element content pointed by index to a temporary location
numArray[index+1] = numArray[index]; // moving the next element contect to the element content pointed by index
numArray[index] = temp ; // moving the element content pointed by index from the temporary location to the next element content pointed by index
}
for(index=0; index<10; index++)
{
printf("%02d ",numArray[index]);
_sleep(time*100);
}
printf("\tTime=0.%ds -UP KEY\n\t\a",time);
if(kbhit())
{
key=getch();
switch(key)
{
case'1':ChangeTime(1);break;
case'2':ChangeTime(2);break;
case'3':ChangeTime(3);break;
case'4':ChangeTime(4);break;
case'6':ChangeTime(6);break;
case'7':ChangeTime(7);break;
case'8':ChangeTime(8);break;
case'9':ChangeTime(9);break;
}
break;
}// a key is detected again and it's not u
}//end of upp key while loop
}
void DOWN() {
while(key!=ESC && key!=u && key==d)
{
/* using for-loop to shift all 10 elements in one go */ for(index=9; index>0; index--)
{
temp = numArray[index]; // moving the element content pointed by index to a temporary location
numArray[index] = numArray[index-1]; // moving the next element contect to the element content pointed by index
numArray[index-1] = temp ; // moving the element content pointed by index from the temporary location to the next element content pointed by index
}
for(index=0; index<10; index++)
{
printf("%02d ",numArray[index]);
_sleep(time*100);
}
printf("\tTime=0.%ds -DOWN KEY\n\t\a",time);
if(kbhit())
{
key=getch();
switch(key)
{
case'1':ChangeTime(1);break;
case'2':ChangeTime(2);break;
case'3':ChangeTime(3);break;
case'4':ChangeTime(4);break;
case'6':ChangeTime(6);break;
case'7':ChangeTime(7);break;
case'8':ChangeTime(8);break;
case'9':ChangeTime(9);break;
}
break;
}// a key is detected again and it's not u
}//end of upp key while loop
}
int ChangeTime(int InputTime)
{
time=InputTime;
}
排那麼整齐很难帮你检查啊.... |
|