Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 3236|回复: 18
打印 上一主题 下一主题

求救C language

[复制链接]

5

主题

0

好友

1733

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

跳转到指定楼层
1#
发表于 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);
    //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 编辑 ]




收藏收藏0

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

2#
发表于 2009-8-1 04:18 PM |只看该作者
原帖由 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;
}



排那麼整齐很难帮你检查啊....


回复

使用道具 举报

5

主题

0

好友

1733

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

3#
发表于 2009-8-1 10:55 PM |只看该作者

回复 #2 Super-Tomato 的帖子

本来是排的很好的
可是一放来这里就


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

4#
发表于 2009-8-1 11:15 PM |只看该作者
原帖由 shetaikeng 于 2009-8-1 10:55 PM 发表
本来是排的很好的
可是一放来这里就


哪麼你的錯誤訊息是甚麼??

才看一下你的 coding 就發現很多 variables 沒有 declare

[ 本帖最后由 Super-Tomato 于 2009-8-1 11:16 PM 编辑 ]


回复

使用道具 举报

5

主题

0

好友

1733

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

5#
发表于 2009-8-2 12:57 AM |只看该作者

回复 #4 Super-Tomato 的帖子

这是我要RUN的东西 他在分开始可以RUN
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #define ESC 27
    #define u 117
    #define d 100
   
    void UPP();
    void DOWN();
    int ChangeTime(int);
    //creating a GLOBAL integer array of 10 elements
   
    int numArray[]={1,2,3,4,5,6,7,8,9,10};
    int time=1;
    char key;
    int index;
    int temp;
   
    int main()
    {
   
        do
        {     
              system("cls");
              //display the outlook
              printf("\tUp/Down Number Rotation\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;
}


可是当我把它跟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 12:59 AM 编辑 ]


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

6#
发表于 2009-8-2 01:34 AM |只看该作者
原帖由 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();
      }
}



這裡你沒寫出 function, 應該不能編譯成功, 還有把你的 syntax error 完整寫出來, 我不想複製你的 coding 去測試


回复

使用道具 举报

5

主题

0

好友

1733

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

7#
发表于 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"
C:\Users\K\Desktop\tingting.cpp: In function `void ChangeUpDownRotationSpeed()':
C:\Users\K\Desktop\tingting.cpp:141: error: return-statement with a value, in function returning 'void'

C:\Users\K\Desktop\tingting.cpp: In function `void UPP()':
C:\Users\K\Desktop\tingting.cpp:146: error: `key' undeclared (first use this function)
C:\Users\K\Desktop\tingting.cpp:146: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Users\K\Desktop\tingting.cpp:149: error: `index' undeclared (first use this function)
C:\Users\K\Desktop\tingting.cpp:151: error: `temp' undeclared (first use this function)
C:\Users\K\Desktop\tingting.cpp:151: error: `numArray' undeclared (first use this function)

C:\Users\K\Desktop\tingting.cpp:159: error: invalid operands of types `time_t ()(time_t*)' and `int' to binary `operator*'
C:\Users\K\Desktop\tingting.cpp: In function `void DOWN()':
C:\Users\K\Desktop\tingting.cpp:184: error: `key' undeclared (first use this function)
C:\Users\K\Desktop\tingting.cpp:187: error: `index' undeclared (first use this function)
C:\Users\K\Desktop\tingting.cpp:189: error: `temp' undeclared (first use this function)
C:\Users\K\Desktop\tingting.cpp:189: error: `numArray' undeclared (first use this function)
C:\Users\K\Desktop\tingting.cpp:196: error: invalid operands of types `time_t ()(time_t*)' and `int' to binary `operator*'
C:\Users\K\Desktop\tingting.cpp: In function `int ChangeTime(int)':
C:\Users\K\Desktop\tingting.cpp:221: error: assignment of function `time_t time(time_t*)'
C:\Users\K\Desktop\tingting.cpp:221: error: cannot convert `int' to `time_t ()(time_t*)' in assignment

Execution terminated
这是那个ERROR


回复

使用道具 举报

5

主题

0

好友

1733

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

8#
发表于 2009-8-2 02:21 PM |只看该作者
#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() 这是但我把它贴进去时命名的function
{
    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;
}


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

9#
发表于 2009-8-2 06:35 PM |只看该作者
原帖由 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"


C:\Users\K\Desktop\tingting.cpp: In function `void ChangeUpDownRotationSpeed()':
C:\Users\K\Desktop\tingting.cpp:141: error: return-statement with a value, in function returning 'void'
你都指定為 void 類型函數, 哪麼你的函數中為何還要用 return???


C:\Users\K\Desktop\tingting.cpp: In function `void UPP()':
C:\Users\K\Desktop\tingting.cpp:146: error: `key' undeclared (first use this function)
C:\Users\K\Desktop\tingting.cpp:146: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Users\K\Desktop\tingting.cpp:149: error: `index' undeclared (first use this function)
C:\Users\K\Desktop\tingting.cpp:151: error: `temp' undeclared (first use this function)
C:\Users\K\Desktop\tingting.cpp:151: error: `numArray' undeclared (first use this function)

寫的很清楚沒declare variables


C:\Users\K\Desktop\tingting.cpp: In function `int ChangeTime(int)':
C:\Users\K\Desktop\tingting.cpp:221: error: assignment of function `time_t time(time_t*)'
C:\Users\K\Desktop\tingting.cpp:221: error: cannot convert `int' to `time_t ()(time_t*)' in assignment

int ChangeTime(int InputTime)
{
     time=InputTime;  
}

time 類型不是 int 當然沒辦法 assign


回复

使用道具 举报

5

主题

0

好友

1733

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

10#
发表于 2009-8-2 09:52 PM |只看该作者

回复 #9 Super-Tomato 的帖子

那请问要如何更改???
我也不知道要如何declare variables


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-10-26 04:23 PM , Processed in 0.169021 second(s), 26 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部