精品偷拍一区二区三区,亚洲精品永久 码,亚洲综合日韩精品欧美国产,亚洲国产日韩a在线亚洲

  • <center id="usuqs"></center>
  • 
    
  • C程序有道題解析看不懂

    C程序有道題解析看不懂
    編寫一個(gè)程序求出兩個(gè)字符串:
    s[]=”Thisis C programming text”
    t[]=”Thisis a text for C programming”
    包含最長(zhǎng)的相同單詞(同一字母的大小寫視為不同的字符).
    程序:
    #include
    #include
    void maxword(char *s,char *t)
    {
    char*res,*temp,chs,cht;
    inti,j,found,maxlen=0;
    while(*s!='\0')
    {
    while(*s==' ') s++;
    for(i=0;s[i]!=' ' && s[i]!='\0';i++);
    if(i>maxlen)
    {
    chs=s[i];
    s[i]='\0';
    temp=t;
    found=0;
    while (*temp!='\0' && found)
    {
    while (*temp==' ') temp++;
    for (j=0;temp[j]!=' ' && temp[j]!='\0';j++);
    if (j==i)
    {
    cht=temp[j];
    temp[j]='\0';
    if (strcmp(s,temp)==0)
    {
    maxlen=i;
    res=s;
    found=1;
    }
    temp[j]=cht;
    }
    temp=&temp[j];
    }
    s[i]=chs;
    }
    s=&s[i];
    }
    if(maxlen==0)
    printf("沒有相同的單詞.\n");
    else
    {
    chs=res[maxlen];
    res[maxlen]='\0';
    printf("%s\n",res);
    res[maxlen]=chs;
    }
    }
    main()
    {
    staticchar s[]="This is C programming text";
    staticchar t[]="This is a text for C programming";
    maxword(s,t);
    }
    看不懂,關(guān)鍵步驟的每一步是干什么用的,設(shè)置的每個(gè)變量分別起什么作用.
    其他人氣:622 ℃時(shí)間:2020-05-19 00:33:19
    優(yōu)質(zhì)解答
    /*將字符串s中的第一個(gè)單詞,與字符串t中的所有單詞比較,看單詞是否相等.然后s中的第二個(gè)單詞比較,這樣依次循環(huán)*/#include #include void maxword(char *s,char *t){char *res,*temp,chs,cht;int i,j,found,maxlen=0;...*res,*temp,chs,cht; ????????????????????for (j=0;temp[j]!=' ' && temp[j]!='\0';j++); ?????к??j?????????????λ???????????λ?????j-1,??????chs=temp[j]?? ???????jλ??????????????cht????*res???????????????temp=t??????temp??t?????в?????????for (j=0;temp[j]!=' ' && temp[j]!='\0';j++);??????temp[0]??temp[j-1]????????temp[j]='\0',???temp?????????????????????
    我來回答
    類似推薦
    請(qǐng)使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點(diǎn),以保證最佳閱讀效果。本頁(yè)提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機(jī)版