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://www.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>

            莱阳市| 泌阳县| 博湖县| 黄平县| 长春市| 紫金县| 盐源县| 南京市| 铜陵市| 塔城市| 孝感市| 观塘区| 常宁市| 马山县| 天门市| 怀化市| 永定县| 曲沃县| 伊宁市| 江城| 宿松县| 塔城市| 儋州市| 上饶县| 丹江口市| 秭归县| 安福县| 满城县| 南丰县| 尚义县| 沁阳市| 高台县| 玛纳斯县| 东城区| 定日县| 天气| 阆中市| 阿克陶县| 澎湖县| 漳浦县| 邮箱|