- 分享
- 0
- 人气
- 0
- 主题
- 5
- 帖子
- 322
- UID
- 14148
- 积分
- 1733
- 阅读权限
- 19
- 注册时间
- 2005-6-14
- 最后登录
- 2016-6-23
- 在线时间
- 239 小时
|
我想问
如何在 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);
//creating a GLOBAL integer array of 10 elements
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 - Lim Liyun <094712W>\n");
printf("\t2. Start/Stop Number Rotation - Yin Yiping <090121R>\n");
printf("\t3. Number Up/Down Rotation - Yu Shengnan <090157F>\n");
printf("\t4. Change Up/Down Rotation Speed - Zhao tingting <094724T>\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)
{
break;
}
}
}//end of kbhit()
}while(key != ESC );
printf("Try again?");
key=getch();
}while(key!='n');
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];
numArray[index+1] = numArray[index];
numArray[index] = temp ;
}
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;
}
}
}
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];
numArray[index] = numArray[index-1];
numArray[index-1] = temp ;
}
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;
}
}
}
int ChangeTime(int InputTime)
{
time=InputTime;
}
[ 本帖最后由 shetaikeng 于 2009-8-1 10:57 PM 编辑 ] |
|