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>

            昌吉市| 如东县| 耒阳市| 咸宁市| 宜宾市| 加查县| 芮城县| 延边| 石台县| 临朐县| 贺州市| 榆林市| 伊金霍洛旗| 铁岭市| 沿河| 石楼县| 当雄县| 常德市| 和政县| 广东省| 泰来县| 蕲春县| 本溪市| 阳江市| 平谷区| 泗阳县| 泽库县| 福州市| 上犹县| 通渭县| 简阳市| 灌阳县| 唐海县| 滨州市| 文安县| 澎湖县| 黄冈市| 新晃| 左贡县| 大城县| 无锡市|