1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      C語言中字符串實(shí)現(xiàn)正序與逆序?qū)嵗斀?/div>

      C語言中字符串實(shí)現(xiàn)逆序?qū)嵗斀?/strong>

      通榆網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),通榆網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為通榆上千多家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的通榆做網(wǎng)站的公司定做!

      字符串逆序和正序的實(shí)現(xiàn)代碼:

      #include 
      
      #include 
      
      #include 
      
      #include 
      
      #include 
      
      /*定義*/
      
      typedef struct node
      
      {
      
       char c;
      
       struct node *llink,*rlink;
      
      }stud;
      
      /*建立鏈表*/
      
      stud * creat(void)
      
      {
      
       stud *p,*h,*s;
      
       char a;
      
       if((h=(stud *)malloc(sizeof(stud)))==NULL)
      
       {
      
        printf("不能分配內(nèi)存空間!");
      
        exit(0);
      
       }
      
       h->c = 0;
      
       h->llink=NULL;
      
       h->rlink=NULL;
      
       p=h;
      
       while(1)
      
       {
      
      a = getchar();
      
      if(a=='\n')
      
      break;
      
        if((s= (stud *) malloc(sizeof(stud)))==NULL)
      
        {
      
         printf("不能分配內(nèi)存空間!");
      
         exit(0);
      
        }
      
        p->rlink=s;
      
        
      
        s->c =a;
      
        s->llink=p;
      
        s->rlink=NULL;
      
        p=s;
      
       }
      
       h->llink=s;
      
       p->rlink=h;
      
       return(h);
      
      }
      
      /*正序*/
      
      void print1(stud *h)
      
      {
      
       stud *p;
      
       p=h->rlink;
      
       printf("字符串(正序):");
      
       while(p!=h)
      
       {
      
        printf("%c",p->c);
      
        p=p->rlink;
      
       }
      
       printf("\n");
      
      }
      
      /*逆序*/
      
      void print2(stud *h)
      
      {
      
       stud *p;
      
       p=h->llink;
      
       printf("字符串(逆序):");
      
       while(p!=h)
      
       {
      
        printf("%c",p->c);
      
        p=p->llink;
      
       }
      
       printf("\n");
      
      }
      
      /*釋放*/
      
      void free_stud(stud *h)
      
      {
      
       stud *p,*q;
      
       p=h->llink;
      
       while(p!=h)
      
       {
      
        q=p;
      
        p=p->llink;
      
        free(q);
      
       }
      
       free(h);
      
      }
      
      /*主函數(shù)*/
      
      int main()
      
      {
      
       stud *head=NULL;
      
       head=creat();
      
       print1(head);
      
       print2(head);
      
       free_stud(head);
      
       return 0;
      
      }

      實(shí)現(xiàn)效果圖:

      C語言中字符串實(shí)現(xiàn)正序與逆序?qū)嵗斀?></p><p>感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!</p>            
            
                                                            <br>
                                                當(dāng)前文章:C語言中字符串實(shí)現(xiàn)正序與逆序?qū)嵗斀?                                               <br>
                                                文章URL:<a href=http://ef60e0e.cn/article/peejdd.html

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
          1. <ul id="0c1fb"></ul>

            <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
            <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

            湖北省| 无棣县| 策勒县| 阳春市| 海口市| 许昌县| 拜城县| 将乐县| 河北区| 临朐县| 裕民县| 敦煌市| 雷波县| 平和县| 夏邑县| 博乐市| 鄯善县| 武冈市| 奇台县| 泰兴市| 应用必备| 永靖县| 秭归县| 海门市| 新干县| 江都市| 柘荣县| 都昌县| 綦江县| 乡城县| 嘉定区| 敖汉旗| 靖宇县| 丹东市| 盖州市| 宜黄县| 朝阳区| 黄石市| 南昌县| 高淳县| 句容市|