青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

隨筆 - 18  文章 - 5  trackbacks - 0
<2025年9月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用鏈接

留言簿

隨筆分類

隨筆檔案

文章分類

文章檔案

程序設計基礎

牛們

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

1. An exercise on lisk
• Write a definition of LIST_ENTRY, and the insertion and deletion operations
• Write a simple line editor
Keep the entire text on a linked list, one line in a separate node. Start the program with entering LINEEDIT file, after which a prompt appears along with the line number. If the letter “I” is entered with a number n following it, then insert the text to be followed before line n. If “I” is not followed by a number, then insert the text before the current line. If “D” is entered with two numbers n and m, one n, or no number following it, then delete lines n through m, line n, or the current line. Do the same with the command, “L”, which stands for listing lines. If “A” is entered, then append the text to the existing lines. Entry “E” signifies exit and saving the text in a file.
//這道題實在做不出,參考了別的同學的…… 
#include<iostream>
#include
<fstream>
using namespace std;
ifstream fin(
"test.txt");
int cl=0;
//建立LIST_ENTRY類 
class LIST_ENTRY
{
    
public:
        
struct node
        {
            
public:
                node 
*next;
                
string s0;
                node(
string s="")
                {
                    s0
=s;
                    next
=NULL;
                }
        }
*first;
        
int l;
        LIST_ENTRY()
        {
            l
=0;
            first
=NULL;
        }
//A命令 
        int ins(string x,int y=cl+1)
        {
            
int t=y-2;
            node 
*p=first,*temp=new node(x);
            
if (t==-1)
            {
                temp
->next=first;
                first
=temp;
                l
++;
                cl
++;
                
return 1;
            }
            
if (p==NULL)
            
return 0;
            
while(t)
            {
                t
--;
                p
=p->next;
                
if(p==NULL)
                
return 0;
            }
            temp
->next=p->next;
            p
->next=temp;
            
if(y==cl+1)
            cl
++;
            
else 
            cl
=y+1;
            l
++;
            
return 1;
        }
//D命令 
        int del(int x)
        {
            node 
*p=first;
            
if (x==1)
            {
                
if (first==NULL)return 0;
                first
=first->next;
                l
--;
                delete p;
                
return 1;
            }
            
if(p==NULL)
            
return 0;
            
while (x-2)
            {
                x
--;
                p
=p->next;
                
if(p==NULL)
                
return 0;
            }
            node 
*temp=p->next;
            
if (temp!=NULL)
            {
                p
->next=temp->next;
                delete temp;
                l
--;
                
return 1;
            }
            
return 0;
        }
//E命令 
        int lis(int x,int y=0,node* p=NULL)
        {
            
if (x==1)
            p
=first;
            
if (y==1&&x==1)
            freopen(
"out.txt","w",stdout);
            
if (p==NULL)
            
return 0;
            cl
=x;
            
if (!y)
            cout
<<cl<<'>';
            cout
<<p->s0<<endl;
            
return lis(x+1,y,p->next);
        }
}a;
int chg(char* c,string &s,int &x,int &y,string &s2)
{
    
int i,j;
    s
="",s2="";
    x
=y=cl;
    
if (c[1]!=' '||(c[0]!='I'&&c[0]!='D'&&c[0]!='A'))
    {
        
for(i=0;c[i];i++)
        s
+=c[i];
        
return 0;
    }
    s
+=c[0];
    
if (c[0]=='A')
    {
        
for (i=2,j=0;c[i];i++)
        {
            
if(c[i]!=' ')j=1;
            
if(j==1)s2+=c[i];
        }
        
return 0;
    }
    
for (i=2;c[i];i++)
        
if (c[i]!=' ')
        {
            
for (j=0;c[i]!=' '&&c[i];i++)
                j
=j*10+c[i]-'0';
            y
=x=j;
            
break;
        }
    
if (c[0]!='D')
    
return 0;
    
for (;c[i];i++)
        
if (c[i]!=' ')
        {
            
for (j=0;c[i]!=' '&&c[i];i++)
            j
=j*10+c[i]-'0';
            y
=j;
            
break;
        }
    
return 0;
}
int main()
{
    
string s,s2;
    
int x,y,i=0,j=0,k=0;
    
char c[1000];
    
while(fin.getline(c,1000,10))
    {
        
for(i=0,s="";c[i];i++)
            s
+=c[i];
        a.ins(s);
    }
    cout
<<"LINEEDIT.txt"<<endl;
    a.lis(
1);
    cout
<<cl<<'>';
    
while(cin.getline(c,1000,10))
    {
        chg(c,s,i,j,s2);
        
if(s=="L")
        {
            k
=0;
            a.lis(
1);
            cout
<<cl<<'>';
            
continue;
        }
        
if(s=="A")
        {
            a.ins(s2);
            cout
<<cl<<'>';
            
continue;
        }
        
if(s=="I")
        {
            k
=2;
            cl
=i;
            cout
<<cl<<'>';
            
continue;
        }
        
if(s=="E")
        {
            k
=0;
            a.lis(
1,1);
            
return 0;
        }
        
if(s=="D")
        {
            
for(k=j;k>=i;k--)
                a.del(k);
            k
=0;
            cl
=a.l;
            cout
<<cl<<'>';
            
continue;
        }
        
if(k==2)
            a.ins(s,cl);
        cout
<<cl<<'>';
    }
    system(
"pause");
    
return 0;
}
2. An exercise on queue
• Write a queue using a doubly linked list
• Simulate a command-dispatching system
– It can accept user?s commands (from „a? – „j?)
– These commands will take 1~10s, respectively
– The user commands will be enqueued if the program can not finish the previous commands
– The program will quit if user inputs command „q?
• Hints:
– Use “_kbhit()” to determine whether user inputs a command
– Use “Sleep(1000)” to simulate the 1-second processing
• Add #include “Windows
posted on 2010-11-01 08:28 jyy 閱讀(146) 評論(0)  編輯 收藏 引用 所屬分類: OJ平臺
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲欧美大片| 国产日韩欧美综合精品| 亚洲欧美日韩成人| 亚洲欧美日韩另类精品一区二区三区 | 久久aⅴ国产紧身牛仔裤| 久久精品91| 免费亚洲一区| 欧美午夜不卡在线观看免费 | 性欧美在线看片a免费观看| 久久www成人_看片免费不卡| 久久综合九色| 日韩午夜激情av| 亚洲欧美在线免费观看| 久热精品在线| 国产精品久久久久一区二区三区共| 国产视频在线观看一区| 亚洲精品女人| 欧美一区二区三区视频免费播放 | 亚洲一区二区三区色| 欧美综合二区| 国产精品igao视频网网址不卡日韩 | 亚洲国产一区二区在线| 亚洲经典在线看| 欧美亚洲一区二区在线观看| 欧美**字幕| 国产日韩精品入口| 一本高清dvd不卡在线观看| 久久久久一区二区| 亚洲午夜精品一区二区三区他趣 | 欧美区视频在线观看| 国内成人精品2018免费看 | 欧美一区二区大片| 亚洲国产成人精品久久久国产成人一区 | 亚洲国产视频a| 久久er99精品| 国产精品三级视频| 一区二区三区四区五区精品视频| 久久视频国产精品免费视频在线| 夜夜嗨av一区二区三区免费区| 欧美日韩成人一区二区| 久久精品成人一区二区三区| 欧美三级乱人伦电影| 亚洲欧洲精品一区二区精品久久久| 亚洲综合精品自拍| 最新中文字幕亚洲| 蜜臀久久99精品久久久久久9| 国产亚洲日本欧美韩国| 午夜在线观看免费一区| 99热免费精品在线观看| 欧美精品成人一区二区在线观看 | 欧美一级淫片播放口| 99精品99| 欧美视频一区二区| 中日韩美女免费视频网址在线观看 | 亚洲国产精品尤物yw在线观看 | 欧美大片免费看| 久久久久久黄| 亚洲成色www8888| 免费永久网站黄欧美| 久久久水蜜桃| 亚洲高清免费| 欧美激情成人在线| 免费日韩av电影| 夜夜嗨av一区二区三区| 日韩视频免费看| 国产精品黄视频| 新片速递亚洲合集欧美合集 | 欧美日韩一区二区欧美激情| 亚洲人成亚洲人成在线观看图片| 亚洲国产成人tv| 欧美乱妇高清无乱码| 亚洲尤物影院| 欧美在线欧美在线| 亚洲韩国日本中文字幕| 亚洲精品网站在线播放gif| 欧美系列一区| 久久久久久电影| 欧美高清视频一二三区| 亚洲午夜av| 欧美在线www| 日韩性生活视频| 亚洲在线中文字幕| 亚洲黄色精品| 亚洲影院一区| 亚洲国产色一区| 宅男在线国产精品| 亚洲承认在线| 一区二区电影免费观看| 欧美在线免费观看亚洲| 久久成人精品一区二区三区| 亚洲黄色一区| 亚洲欧美网站| 亚洲精品乱码久久久久久久久| av成人免费在线观看| 曰本成人黄色| 一区二区久久久久久| 国产专区欧美专区| 亚洲精品一区二区三区av| 国产一区二区三区观看| 日韩视频在线观看一区二区| 一区福利视频| 99在线精品视频| 亚洲激情图片小说视频| 午夜精品999| 亚洲视频中文字幕| 男女激情久久| 久久久久久伊人| 欧美色中文字幕| 欧美国产日韩精品免费观看| 国产日韩在线不卡| 日韩视频久久| 亚洲精品一区二区网址| 久久高清国产| 欧美在线不卡视频| 欧美性做爰毛片| 亚洲国产另类精品专区 | 欧美成人精品1314www| 久久久av水蜜桃| 国产精品久久久久久久一区探花| 亚洲高清不卡| 亚洲第一黄色网| 久久久久青草大香线综合精品| 先锋影音国产精品| 欧美偷拍一区二区| 亚洲精品免费一二三区| 亚洲国内在线| 欧美成人一区二区三区片免费| 蜜臀av性久久久久蜜臀aⅴ四虎| 国产欧美综合在线| 亚洲在线视频| 亚洲欧美日韩在线播放| 欧美视频精品一区| 一本大道久久a久久精二百| 在线一区亚洲| 欧美精品日韩一本| 最新热久久免费视频| 亚洲精品国产视频| 欧美精品二区| 一区二区三区免费看| 午夜一区不卡| 国产视频一区欧美| 久久婷婷国产综合尤物精品| 欧美不卡在线视频| 亚洲九九精品| 欧美三级精品| 午夜免费久久久久| 欧美aaa级| 一区二区日韩伦理片| 国产精品夫妻自拍| 欧美一区二区三区免费看| 久久夜色精品国产欧美乱极品| 狠狠入ady亚洲精品| 久久综合九九| 亚洲一区日本| 欧美在线看片| 欧美ab在线视频| 一本色道久久综合| 国产精品高潮在线| 欧美一区二区免费视频| 蜜臀av性久久久久蜜臀aⅴ| 亚洲国产精品久久久久秋霞不卡| 欧美第一黄色网| 中文av字幕一区| 久久综合激情| 亚洲天堂av综合网| 激情小说另类小说亚洲欧美| 免费影视亚洲| 亚洲综合国产| 亚洲国产精品久久久久秋霞不卡| 午夜国产精品视频| 在线免费高清一区二区三区| 欧美日韩亚洲一区二区| 久久久久久高潮国产精品视| 亚洲精品视频在线观看网站| 久久蜜臀精品av| 亚洲一区二区三区中文字幕在线| 狠狠久久亚洲欧美| 欧美亚韩一区| 欧美高清免费| 久久久久久久高潮| 亚洲桃色在线一区| 欧美福利一区| 久久精品一二三区| 在线视频中文亚洲| 在线免费高清一区二区三区| 国产精品欧美经典| 欧美日韩亚洲综合一区| 美女国产一区| 久久国产精品一区二区| 一区二区三区视频在线| 亚洲国产cao| 农夫在线精品视频免费观看| 久久精品视频网| 先锋影音久久| 亚洲影院色无极综合| 亚洲美洲欧洲综合国产一区| 禁断一区二区三区在线| 国产精品色婷婷| 国产精品男人爽免费视频1| 欧美午夜剧场|