原帖由 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;
}
原帖由 shetaikeng 于 2009-8-2 12:57 AM 发表
可是当我把它跟MENU PAGE 加在一起时
他就出现SYNTAX ERROR
我不知道如何解决
这是MENU PAGE的
#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();
}
}
原帖由 shetaikeng 于 2009-8-2 02:19 PM 发表
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Users\K\Desktop\tingting.cpp" -o "C:\Users\K\Desktop\tingting.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
欢迎光临 JBTALKS.CC (https://www.jbtalks.cc/) | Powered by Discuz! X2.5 |