王发启吧 关注:4贴子:122
  • 5回复贴,共1

吧主,... 我错了 我这学期没有好好学习C 帮我看一道题目好不

收藏回复

  • 222.212.252.*
函数fun功能是:将字符串a的第m个字符开始的全部字符复制到字符串b中。在main函数中调用fun函数并输出复制结果。例如,字符串a为"Computer",m=4,则字符串b为"puter"。调试程序使之能输出正确的结果。
void fun(char a[ ],char b[ ],int m)
{
 ……
}
我们机械专业 然后我也苯了 感觉老是学不好


1楼2007-06-24 18:54回复
    • 219.150.167.*
    #include"stdio.h"
    #include"conio.h"
    #define N 20
    #define M 20
    int notnull(char a[],int y)
    {for(;(a[y]>='\0')&&y>=0;y--) if(a[y]!=0) break;
     if (y>=0) return ++y;
     else return 0;
    }
    void fun(char a[ ],char b[ ],int m) 
    { int i,j;
     j=notnull(a,20);

     for(i=m-1;i<j;i++) b[i-(m-1)]=a[i];
     puts(b);
     

    main()
    {char a[N]="Computer",b[M];
     fun(a,b,4);
     getch();
     
    }


    2楼2007-08-07 06:55
    回复
      • 219.150.167.*
      好长时间没来了,不好意


      3楼2007-08-07 06:56
      回复
        • 219.150.167.*
        时间快到了,下次再给你解


        4楼2007-08-07 06:57
        回复
          • 219.150.167.*
          #include"stdio.h" 
          #include"conio.h" 
          #define N 20 
          #define M 20 
          int notnull(char a[],int y) 
          {for(;(a[y]>='\0')&&y>=0;y--) if(a[y]!=0) break; 
           if (y>=0) return ++y; 
           else return 0; 

          void fun(char a[ ],char b[ ],int m) 
          { int i,j; 
           j=notnull(a,20); 

           for(i=m-1;i<j;i++) b[i-(m-1)]=a[i]; 
           for(i=0;i<j;i++) printf("%c",b[i]);
           

          main() 
          {char a[N]="Computer",b[M]; 
           fun(a,b,4); 
           getch(); 
           
          }


          5楼2007-08-07 06:58
          回复
            • 222.89.251.*
            忘了对数组b初始化了

             #include"stdio.h" 
            #include"conio.h" 
            #define N 20 
            #define M 20 
            int notnull(char a[],int y) 
            {for(;(a[y]>='\0')&&y>=0;y--) if(a[y]!=0) break; 
             if (y>=0) return ++y; 
             else return 0; 

            void fun(char a[ ],char b[ ],int m) 
            { int i,j; 
             j=notnull(a,N-1); 

             for(i=m-1;i<j;i++) b[i-(m-1)]=a[i]; 
             for(i=0;i<j-(m-1);i++) printf("%c",b[i]); 
             

            main() 
            {char a[N]="Computer",b[M]=""; 
             fun(a,b,4); 
             getch(); 
             
            }


            6楼2007-09-01 18:59
            回复