| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 566 人关注过本帖
标题:高手请进,谢谢啦
只看楼主 加入收藏
tmjnng
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2010-6-30
结帖率:100%
收藏
已结贴  问题点数:6 回复次数:7 
高手请进,谢谢啦
帮我找出这个程序的错误,万急!(要用TC)
int n,i=0,j,k=0,resu;
char s1[100],s2[100], s[100];
#include "stdio.h"
void main()
{void cpy(char str1[],char str2[]);
 char s1[100],s2[100];
 /*Print Welcome screen and the main interface*/
 printf("\n\n");
 printf("a           w eeeeeee  l      ccccccc  ooooo   mmmmmmmmm  eeeeeee     !!!!\n");
 printf("w     w     w e     e  l      c       o     o  m   m   m  e     e     !!! \n");
 printf(" w   w w   w  e eeeee  l      c      o       o m   m   m  eeeeeee     !!  \n");
 printf("  w w   w w   e        l      c       o     o  m   m   m  e           !   \n");
 printf("   w     w    eeeeeee  llllll ccccccc  ooooo   m   m   m  eeeeeee         \n");
 for(;;)
 {
 int sum=0;
 printf("\n");
 printf("\t****************MENU*******************************\n");
 printf("\t*       Common Algorithm String                     *\n");
 printf("\t*        1.Copy string                          *\n");
 printf("\t*         strings                        *\n");
 printf("\t*        3.Request the length of the string                       *\n");
 printf("\t*        4.Connect the two strings                        *\n");
 printf("\t*        5.The character ch converted to lower case mother                *\n");
 printf("\t*        6.The character ch converted to upper case letters                 *\n");
 printf("\t*        7.Check if the letters ch                       *\n");
 printf("\t*        8.Check whether the number of ch                       *\n");
 printf("\t*        9.Ch check whether the letters or numbers            *\n");
 printf("\t*        10.Check whether ch capital letters (A - Z)       *\n");
 printf("\t*        11.Check whether ch lowercase letters (a - z)         *\n");
 printf("\t*        12.Quit                                  *\n");
 printf("\t***************************************************\n");
 printf("\nPlease choose the number n:");
 scanf("%d",&n);
 while (n<=0||n>13)
   {
        printf("Please choose the number again n:");
        scanf("%d",&n);
   }
 switch( n)
    {   
        case 1:                        /*字符串的复制*/
                 clrscr();  
                 getchar();            /*抵消回车*/                                       
                 printf("input string1:");
                 gets(s1);
                 j=0;
                 for (i=0;s1[i]!='\0';i++) s2[i]=s1[i];
                 printf("\nThe new string is:%s\n", s2);
                 break;
                 
        case 2:  
                 clrscr();
                 getchar();                                           /*字符串的比较 */
                 printf("\ninput string1:");
                 gets(s1);
                 printf("\ninput string2:");
                   gets(s2);
                   i=0;
                  while ((s1[i]==s2[i])&&(s1[i]!='\0'))i++;
                  if (s1[i]=='\0'&& s2[i]=='\0')     resu =0;
                  else
                 resu=s1[i]-s2[i];
                   if(resu==0)
                  printf("s1=s2");
                   else if(resu>0)
                   printf("s1>s2");
                   else
                   printf("s1<s2");
                 break;   
        case 3:
                clrscr();   
                getchar();                                               /*求字符串的长度  */
                printf("\ninput string:");
                gets(s);
                for(i=0;s[i]!='\0';i++)
                sum=sum+1;
                printf("The length of the string is:%d", sum);
                break;
        case 4:
               clrscr();
               j=0;
               i=0;
               getchar();                                              /*连接两个字符*/
               printf("\nput string1:");
               gets(s1);
               printf("input string2:");
               gets(s2);
               while(s1[i]!='\0')
                i++;
               while(s2[j]!='\0')
               s1[i++]=s2[j++];
               s1[i]='\0';
               printf("the new string is:%s\n",s1);
               break;        
        case 5:
               clrscr();
               printf("input string:");     /*将ch字符转换为小写母*/
               getchar();
               gets(s);
               for(i=0;s[i]!='\0';i++)
               if(s[i]>=65 && s[i]<=90)
               printf("%c",s[i]);
               else if(s[i]>=97 && s[i]<=122)
               {s[i]=s[i]-32;
               printf("%c",s[i]);
               }
               else
               printf("%c",s[i]);
               break;
        case 6:
                clrscr();
                getchar();     
                printf("input string:");                     /*将ch字符转换为大写字母 */
                gets(s);
                for(i=0;s[i]!='\0';i++)
                if(s[i]>=97 && s[i]<=122)
                printf("%c",s[i]);
                else if(s[i]>=65 && s[i]<=90)
                {s[i]=s[i]+32;
                printf("%c",s[i]);
                }
                else
                printf("%c",s[i]);
                break;
        case 7:   
               clrscr();
                getchar();                                          /*检查ch是否是字母 */
               printf("input  string :");
               gets(s);
                for(i=0;s[i]!='\0';i++)
               {
                   if( (s[i]>=65 && s[i]<=90) || (s[i]>=97 && s[i]<=122)||(s[i]==' '))
                continue;
                else
                k=1;
               }
               if(k==0)
               printf("The string is  alpha.");
               else   
               printf("The string is not alpha.");
               break;
        case 8:   
               clrscr();
               getchar();                                           /*检查ch是否是数字 */
               printf("input  string :");
               gets(s);
               for(i=0;s[i]!='\0';i++)
               {if( (s[i]>=48 && s[i]<=57) || (s[i]==' '))
               continue;
               else
               k=1;}
               if(k==0)
               printf("The string is  numeric.");
               else   
               printf("The string is not numeric.");
               break;
        case  9:                                                 /* 检查ch是否由字母或数字组成  */
               clrscr();
               k=0;
               getchar();                                    
               printf("input  string :");
                gets(s);
                for(i=0;s[i]!='\0';i++)
               {
               if((s[i]>=65 && s[i]<=90) || (s[i]>=97 && s[i]<=122)||(s[i]==' ')|| (s[i]>=48 && s[i]<=57) )
               continue;
            
               k=1;}
               if(k==0)
               printf("The string is  numeric or alpha .");
               else   
               printf("The string is not numeric or alpha.");
               break;
        case 10:                                      /*检查ch是否大写字母(A——Z)*/   
               clrscr();
               getchar();                 
               printf("input  string :");
               gets(s);                                    
               for(i=0;s[i]!='\0';i++)
               {
               if( (s[i]>=65 && s[i]<=90) ||(s[i]==' '))
               continue;
               else
               k=1;
               }
               if(k==0)
               printf("The string is capital letter.");
               else   
               printf("The string is not capital letter.");   
               break;
        case 11:
               clrscr();
               getchar();
               printf("input  string :");
               gets(s);                                             
               for(i=0;s[i]!='\0';i++)
               {
               if( (s[i]>=97 && s[i]<=122) ||(s[i]==' '))
               continue;
               else
               k=1;
               }
               if(k==0)
               printf("The string is small letter.");
               else   
               printf("The string is not small letter.");   
               break;              
         case 12:
               clrscr();           /*退出界面*/
               printf("\n");
               printf("\tBBBBB      Y     Y      BBBBB    !!!!!    \n");
                 printf("\tB     B     Y   Y       B     B  !!!!     \n");
                printf("\tBBBBB         Y         BBBB     !!!      \n");
                printf("\tB     B       Y         B     B  !!       \n");
                printf("\tBBBBB         Y         BBBBB    !        \n");
     }
 }
}
搜索更多相关主题的帖子: interface ccccccc Welcome include screen 
2010-07-12 15:43
sunyh1999
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:14
帖 子:1178
专家分:3032
注 册:2009-5-17
收藏
得分:3 
int n,i=0,j,k=0,resu;
char s1[100],s2[100], s[100];
#include "stdio.h"
#include <string.h>
#include <conio.h>
#include<stdlib.h>
void main()
{void cpy(char str1[],char str2[]);
char s1[100],s2[100];
/*Print Welcome screen and the main interface*/
printf("\n\n");
printf("a           w eeeeeee  l      ccccccc  ooooo   mmmmmmmmm  eeeeeee     !!!!\n");
printf("w     w     w e     e  l      c       o     o  m   m   m  e     e     !!! \n");
printf(" w   w w   w  e eeeee  l      c      o       o m   m   m  eeeeeee     !!  \n");
printf("  w w   w w   e        l      c       o     o  m   m   m  e           !   \n");
printf("   w     w    eeeeeee  llllll ccccccc  ooooo   m   m   m  eeeeeee         \n");
for(;;)
{
int sum=0;
printf("\n");
printf("\t****************MENU*******************************\n");
printf("\t*       Common Algorithm String                     *\n");
printf("\t*        1.Copy string                          *\n");
printf("\t*         strings                        *\n");
printf("\t*        3.Request the length of the string                       *\n");
printf("\t*        4.Connect the two strings                        *\n");
printf("\t*        5.The character ch converted to lower case mother                *\n");
printf("\t*        6.The character ch converted to upper case letters                 *\n");
printf("\t*        7.Check if the letters ch                       *\n");
printf("\t*        8.Check whether the number of ch                       *\n");
printf("\t*        9.Ch check whether the letters or numbers            *\n");
printf("\t*        10.Check whether ch capital letters (A - Z)       *\n");
printf("\t*        11.Check whether ch lowercase letters (a - z)         *\n");
printf("\t*        12.Quit                                  *\n");
printf("\t***************************************************\n");
printf("\nPlease choose the number n:");
scanf("%d",&n);
while (n<=0||n>13)
   {
        printf("Please choose the number again n:");
        scanf("%d",&n);
   }
switch( n)
    {   
        case 1:                        /*字符串的复制*/
                 system("CLS");
                 getchar();            /*抵消回车*/                                       
                 printf("input string1:");
                 gets(s1);
                 j=0;
                 for (i=0;s1[i]!='\0';i++) s2[i]=s1[i];
                 printf("\nThe new string is:%s\n", s2);
                 break;
                 
        case 2:  
                system("CLS");

                 getchar();                                           /*字符串的比较 */
                 printf("\ninput string1:");
                 gets(s1);
                 printf("\ninput string2:");
                   gets(s2);
                   i=0;
                  while ((s1[i]==s2[i])&&(s1[i]!='\0'))i++;
                  if (s1[i]=='\0'&& s2[i]=='\0')     resu =0;
                  else
                 resu=s1[i]-s2[i];
                   if(resu==0)
                  printf("s1=s2");
                   else if(resu>0)
                   printf("s1>s2");
                   else
                   printf("s1<s2");
                 break;   
        case 3:
                system("CLS");
   
                getchar();                                               /*求字符串的长度  */
                printf("\ninput string:");
                gets(s);
                for(i=0;s[i]!='\0';i++)
                sum=sum+1;
                printf("The length of the string is:%d", sum);
                break;
        case 4:
               system("CLS");

               j=0;
               i=0;
               getchar();                                              /*连接两个字符*/
               printf("\nput string1:");
               gets(s1);
               printf("input string2:");
               gets(s2);
               while(s1[i]!='\0')
                i++;
               while(s2[j]!='\0')
               s1[i++]=s2[j++];
               s1[i]='\0';
               printf("the new string is:%s\n",s1);
               break;        
        case 5:
               system("CLS");

               printf("input string:");     /*将ch字符转换为小写母*/
               getchar();
               gets(s);
               for(i=0;s[i]!='\0';i++)
               if(s[i]>=65 && s[i]<=90)
               printf("%c",s[i]);
               else if(s[i]>=97 && s[i]<=122)
               {s[i]=s[i]-32;
               printf("%c",s[i]);
               }
               else
               printf("%c",s[i]);
               break;
        case 6:
                system("CLS");

                getchar();     
                printf("input string:");                     /*将ch字符转换为大写字母 */
                gets(s);
                for(i=0;s[i]!='\0';i++)
                if(s[i]>=97 && s[i]<=122)
                printf("%c",s[i]);
                else if(s[i]>=65 && s[i]<=90)
                {s[i]=s[i]+32;
                printf("%c",s[i]);
                }
                else
                printf("%c",s[i]);
                break;
        case 7:   
               system("CLS");
 
                getchar();                                          /*检查ch是否是字母 */
               printf("input  string :");
               gets(s);
                for(i=0;s[i]!='\0';i++)
               {
                   if( (s[i]>=65 && s[i]<=90) || (s[i]>=97 && s[i]<=122)||(s[i]==' '))
                continue;
                else
                k=1;
               }
               if(k==0)
               printf("The string is  alpha.");
               else   
               printf("The string is not alpha.");
               break;
        case 8:   
               system("CLS");

               getchar();                                           /*检查ch是否是数字 */
               printf("input  string :");
               gets(s);
               for(i=0;s[i]!='\0';i++)
               {if( (s[i]>=48 && s[i]<=57) || (s[i]==' '))
               continue;
               else
               k=1;}
               if(k==0)
               printf("The string is  numeric.");
               else   
               printf("The string is not numeric.");
               break;
        case  9:                                                 /* 检查ch是否由字母或数字组成  */
               system("CLS");

               k=0;
               getchar();                                    
               printf("input  string :");
                gets(s);
                for(i=0;s[i]!='\0';i++)
               {
               if((s[i]>=65 && s[i]<=90) || (s[i]>=97 && s[i]<=122)||(s[i]==' ')|| (s[i]>=48 && s[i]<=57) )
               continue;
            
               k=1;}
               if(k==0)
               printf("The string is  numeric or alpha .");
               else   
               printf("The string is not numeric or alpha.");
               break;
        case 10:                                      /*检查ch是否大写字母(A——Z)*/   
               system("CLS");

               getchar();                 
               printf("input  string :");
               gets(s);                                    
               for(i=0;s[i]!='\0';i++)
               {
               if( (s[i]>=65 && s[i]<=90) ||(s[i]==' '))
               continue;
               else
               k=1;
               }
               if(k==0)
               printf("The string is capital letter.");
               else   
               printf("The string is not capital letter.");   
               break;
        case 11:
               system("CLS");

               getchar();
               printf("input  string :");
               gets(s);                                             
               for(i=0;s[i]!='\0';i++)
               {
               if( (s[i]>=97 && s[i]<=122) ||(s[i]==' '))
               continue;
               else
               k=1;
               }
               if(k==0)
               printf("The string is small letter.");
               else   
               printf("The string is not small letter.");   
               break;              
         case 12:
               system("CLS");
           /*退出界面*/
               printf("\n");
               printf("\tBBBBB      Y     Y      BBBBB    !!!!!    \n");
                 printf("\tB     B     Y   Y       B     B  !!!!     \n");
                printf("\tBBBBB         Y         BBBB     !!!      \n");
                printf("\tB     B       Y         B     B  !!       \n");
                printf("\tBBBBB         Y         BBBBB    !        \n");
     }
}
}
这样就好了,你看看

欢迎来到我的博客:http://blog..cn/noisunyuhong
2010-07-12 15:59
do8do8do8
Rank: 10Rank: 10Rank: 10
来 自:沙滩
等 级:贵宾
威 望:17
帖 子:366
专家分:1845
注 册:2010-7-2
收藏
得分:3 
int n,i=0,j,k=0,resu;
char s1[100],s2[100], s[100];
#include "stdio.h"
除了把
#include "stdio.h"
放到最前面
 再加#include <conio.h>

我调试过了没有错。

学C语言从底层开始,学编程从问题开始,一日学会C!!!
2010-07-12 16:09
sunyh1999
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:14
帖 子:1178
专家分:3032
注 册:2009-5-17
收藏
得分:0 
嗯,对的顶顶楼上,lz的清屏函数在我的vc不支持........,只好用system(“CLS”);,楼主不要见怪啊

欢迎来到我的博客:http://blog..cn/noisunyuhong
2010-07-12 16:13
sunyh1999
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:14
帖 子:1178
专家分:3032
注 册:2009-5-17
收藏
得分:0 
改回来就行了

欢迎来到我的博客:http://blog..cn/noisunyuhong
2010-07-12 16:14
tmjnng
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2010-6-30
收藏
得分:0 
非常感谢两位,我会的
2010-07-13 20:26
ggyy4k
Rank: 5Rank: 5
等 级:职业侠客
帖 子:111
专家分:334
注 册:2010-6-28
收藏
得分:0 
回复 楼主 tmjnng
还是有BUG,当输入时直接回车,再输入,再回车,程序就陷入死循环了
2010-07-14 10:45
快速回复:高手请进,谢谢啦
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020065 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved