日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Spreadsheet Tracking

發(fā)布時間:2024/4/30 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spreadsheet Tracking 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

原題及翻譯

Data in spreadsheets are stored in cells, which are organized in rows ? and columns ?.
電子表格中的數(shù)據(jù)存儲在單元格中,單元格按行(R)和列(C)組織。
Some operations on spreadsheets can be applied to single cells (r, c), while others can be applied to entire rows or columns.
電子表格上的某些操作可以應(yīng)用于單個單元格(R、C),而其他操作可以應(yīng)用于整個行或列。
Typical cell operations include inserting and deleting rows or columns and exchanging cell contents.
典型的單元操作包括插入和刪除行或列以及交換單元內(nèi)容。
Some spreadsheets allow users to mark collections of rows or columns for deletion, so the entire collection can be deleted at once.
有些電子表格允許用戶標記要刪除的行或列集合,因此可以一次刪除整個集合。
Some (unusual) spreadsheets allow users to mark collections of rows or columns for insertions too.
一些(不尋常的)電子表格也允許用戶標記行或列的集合進行插入。
Issuing an insertion command results in new rows or columns being inserted before each of the marked rows or columns.
發(fā)出插入命令將導(dǎo)致在每個標記的行或列之前插入新的行或列。
Suppose, for example, the user marks rows 1 and 5 of the spreadsheet on the left for deletion.
例如,假設(shè)用戶將電子表格左側(cè)的第1行和第5行標記為刪除。
The spreadsheet then shrinks to the one on the right.
然后電子表格縮小到右邊的那個。

If the user subsequently marks columns 3, 6, 7, and 9 for deletion, the spreadsheet shrinks to this.
如果用戶隨后將第3、6、7和9列標記為刪除,則電子表格將縮小到此列。

If the user marks rows 2, 3 and 5 for insertion, the spreadsheet grows to the one on the left.
如果用戶將第2、3和5行標記為插入,則電子表格將變?yōu)樽髠?cè)的一行。
If the user then marks column 3 for insertion, the spreadsheet grows to the one in the middle.
如果用戶隨后將第3列標記為插入,則電子表格將增長到中間的一列。
Finally, if the user exchanges the contents of cell (1,2) and cell (6,5), the spreadsheet looks like the one on the right.
最后,如果用戶交換單元格(1,2)和單元格(6,5)的內(nèi)容,那么電子表格看起來就像右邊的一樣。

You must write tracking software that determines the final location of data in spreadsheets that result from row, column, and exchange operations similar to the ones illustrated here.
您必須編寫跟蹤軟件來確定數(shù)據(jù)在電子表格中的最終位置,這些位置是由行、列和交換操作產(chǎn)生的,與此處所示類似。

Input

輸入
The input consists of a sequence of spreadsheets, operations on those spreadsheets, and queries about them.
輸入由一系列電子表格、對這些電子表格的操作以及有關(guān)它們的查詢組成。
Each spreadsheet definition begins with a pair of integers specifying its initial number of rows? and columns ?, followed by an integer specifying the number (n) of spreadsheet operations.
每個電子表格定義以一對整數(shù)開始,指定其初始行數(shù)(r)和列數(shù)(c),然后是一個整數(shù),指定電子表格操作的數(shù)目(n)。
Row and column labeling begins with 1.
行和列標簽以1開頭。
The maximum number of rows or columns of each spreadsheet is limited to 50.
每個電子表格的最大行數(shù)或列數(shù)限制為50。
The following n lines specify the desired operations.
以下n行指定所需的操作。
An operation to exchange the contents of cell (r1, c1) with the contents of cell (r2,c2) is given by:EX r1 c1 r2 c2
將單元(R1,C1)的內(nèi)容物與單元(R2,C2)的內(nèi)容物交換的操作由:ex r1 c1 r2 c2給出。
The four insert and delete commands—DC (delete columns), DR (delete rows), IC (insert columns), and IR (insert rows) are given by:< command > A x1 x2 . . . xA
四個插入和刪除命令dc(刪除列)、dr(刪除行)、ic(插入列)和ir(插入行)由:a x1 x2給出。…XA
where < command > is one of the four commands; A is a positive integer less than 10, and x1, . . . , xA are the labels of the columns or rows to be deleted or inserted before.
其中是四個命令之一;a是小于10的正整數(shù),x1,?!?#xff0c;xa是要刪除或插入的列或行的標簽。
For each insert and delete command, the order of the rows or columns in the command has no significance.
對于每個插入和刪除命令,命令中的行或列的順序沒有意義。
Within a single delete or insert command, labels will be unique.
在單個刪除或插入命令中,標簽將是唯一的。
The operations are followed by an integer which is the number of queries for the spreadsheet.
操作后面是一個整數(shù),它是電子表格的查詢數(shù)。
Each query consists of positive integers r and c, representing the row and column number of a cell in the original spreadsheet.
每個查詢由正整數(shù)r和c組成,表示原始電子表格中單元格的行和列號。
For each query, your program must determine the current location of the data that was originally in cell (r, c).
對于每個查詢,程序必須確定原始數(shù)據(jù)在單元格(r,c)中的當(dāng)前位置。
The end of input is indicated by a row consisting of a pair of zeros for the spreadsheet dimensions.
輸入的結(jié)尾由一行表示,該行由一對用于電子表格維度的零組成。

Output

輸出
For each spreadsheet, your program must output its sequence number (starting at 1).
對于每個電子表格,程序必須輸出其序列號(從1開始)。
For each query, your program must output the original cell location followed by the final location of the data or the word ‘GONE’ if the contents of the original cell location were destroyed as a result of the operations.
對于每個查詢,如果操作導(dǎo)致原始單元格位置的內(nèi)容被破壞,則程序必須輸出原始單元格位置,后跟數(shù)據(jù)的最終位置或單詞“Gone”。
Separate output from di?erent spreadsheets with a blank line.
用空行將不同電子表格的輸出分開。
The data file will not contain a sequence of commands that will cause the spreadsheet to exceed the maximum size.
數(shù)據(jù)文件將不包含將導(dǎo)致電子表格超過最大大小的命令序列。

思路

最直接的思路就是首先模擬操作,算出最后的電子表格,然后在每次查詢時直接在電子表格中找到所求的單元格。

基本思路就是利用三個二維數(shù)組和一個一維數(shù)組進行轉(zhuǎn)換:

int r,c,n,d[maxd][maxd],d2[maxd][maxd],ans[maxd][maxd],cols[maxd]; //r——行數(shù),c——列數(shù),n——操作數(shù) //d用于存儲最初的電子表格,d2用于中間進行操作的電子表格,ans用于存儲最終的電子表格

代碼分析

#include <stdio.h> #include <string.h> #define maxd 100 #define BIG 10000 int r,c,n,d[maxd][maxd],d2[maxd][maxd],ans[maxd][maxd],cols[maxd]; //r——行數(shù),c——列數(shù),n——操作數(shù) //d用于存儲最初的電子表格,d2用于中間進行操作的電子表格,ans用于存儲最終的電子表格 void copy(char type,int p,int q) {if(type=='R'){//如果是行for(int i=1;i<=c;i++){//讓d第p行的每一列等于d2第q行的每一列d[p][i]=d2[q][i];}}else{//如果是列for(int i=1;i<=r;i++){//讓d第p列的每一行等于d2第q列的每一行d[i][p]=d2[i][q];}} } void del(char type) {memcpy(d2,d,sizeof(d));//從d內(nèi)存地址的起始位置開始拷貝整個d到d2內(nèi)存地址中。int cnt=type=='R'?r:c,cnt2=0;//確定刪除的是行/列?for(int i=1;i<=cnt;i++){if(!cols[i]) copy(type,++cnt2,i);//如果該行/列為0,拷貝}if(type=='R') r=cnt2;//如果是行操作,記錄新的行總數(shù)else c=cnt2;//如果是列操作,記錄新的列總數(shù) } void ins(char type) {memcpy(d2,d,sizeof(d));int cnt=type=='R'?r:c,cnt2=0;for(int i=1;i<=cnt;i++){if(cols[i]) copy(type,++cnt2,0);copy(type,++cnt2,i);}if(type=='R') r=cnt2;else c=cnt2; } int main () {int r1,c1,r2,c2,q,kase=0;//kase用于輸出標號char cmd[10];memset(d,0,sizeof(d));while(scanf("%d%d%d",&r,&c,&n)==3&&r){//讀入行列數(shù)和操作數(shù)int r0=r,c0=c;//記錄初始的行和列for(int i=1;i<=r;i++){for(int j=1;j<=c;j++){d[i][j]=i*BIG+j;//先將電子表的每一個單元格初始化}}while(n--){scanf("%s",cmd);//讀入命令if(cmd[0]=='E'){//交換單元格命令scanf("%d%d%d%d",&r1,&c1,&r2,&c2);int t=d[r1][c1];d[r1][c1]=d[r2][c2];d[r2][c2]=t;}else{//如果是插入/刪除命令int a,x;scanf("%d",&a);//a用于存儲要插入/刪除的行/列的個數(shù)memset(cols,0,sizeof(cols));//創(chuàng)建一個全為零的行/列for(int i=0;i<a;i++){//用于讀入要執(zhí)行插入/刪除操作的行/列scanf("%d",&x);//讀入行/列cols[x]=1;//將該行/列設(shè)置為1}if(cmd[0]=='D') del(cmd[1]);//如果是刪除操作else ins(cmd[1]);//如果是插入操作}}memset(ans,0,sizeof(ans));//將最終結(jié)果的電子表格全部初始化為0for(int i=1;i<=r;i++){for(int j=1;j<=c;j++){ans[d[i][j]/BIG][d[i][j]%BIG]=i*BIG+j;}}if(kase>0) printf("\n");printf("Spreadsheet #%d\n",++kase);scanf("%d",&q);//讀入要查詢的個數(shù)while(q--){scanf("%d%d",&r1,&c1);//讀入要查詢的行列數(shù)printf("Cell data in (%d,%d) ",r1,c1);if(ans[r1][c1]==0) printf("GONE\n");//if the contents of the original cell location were destroyedelse printf("moved to (%d,%d)\n",ans[r1][c1]/BIG,ans[r1][c1]%BIG);//打印查詢單元格改變后的位置}}return 0; } 與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖

總結(jié)

以上是生活随笔為你收集整理的Spreadsheet Tracking的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美色第一页 | 99精品中文字幕 | 1024手机在线看片 | 97人人爽人人 | 国产中文字幕第一页 | 黄色免费版| 国产精品国语自产拍在线观看 | 黄色a级免费 | 亚洲深夜av | 少妇久久久久久久 | 国产一级片一区二区 | 欧美猛男gaygay | 一级黄色视 | 成人日韩视频 | 456亚洲影院 | 亚洲日本在线观看视频 | 韩国三级在线看 | 爱爱视频在线播放 | 毛片动态图| 9.1在线观看免费 | 成人免费观看在线视频 | 欧美一区二区三区视频 | 中文字幕国产一区二区 | 99久久夜色精品国产亚洲 | 在线看黄色的网站 | 手机看片国产日韩 | 日韩性生交大片免费看 | 懂色av蜜臀av粉嫩av分 | 一级黄色视 | 亚洲国产视频在线观看 | bbbbbbbbb毛片大片按摩 | 亚洲影视一区 | 天天做天天爱天天爽综合网 | 欧美成人r级一区二区三区 中文无码一区二区三区在线观看 | 日本一区二区视频在线观看 | 国产精品久久久久久婷婷天堂 | 国产精品国语自产拍在线观看 | 免费超碰在线观看 | 精品乱码久久久久久中文字幕 | 青青国产在线视频 | 亚洲成人一区二区在线观看 | 国产视频一二三四区 | 伊人影院在线播放 | 婷婷六月网| 国产成人自拍视频在线观看 | 日本公妇乱偷中文字幕 | 四虎影视免费在线观看 | 国产一区二区三区在线观看视频 | jizzjizzjizz国产 | 天天弄天天干 | 麻豆传媒网址 | 午夜高清视频 | 亚洲乱亚洲乱妇 | 天天草综合| 久久99精品国产麻豆婷婷洗澡 | 黄色片子一级 | 你懂得在线视频 | 亚洲美女屁股眼交8 | а√天堂资源在线 | 精精国产xxxx视频在线播放 | 韩国国产在线 | av在线高清观看 | 小箩莉末发育娇小性色xxxx | 亚洲无码精品免费 | 不卡日本视频 | 欧洲成人精品 | 成人手机在线视频 | 久久免费视频网站 | 综合网在线视频 | 日韩欧美成人一区 | 久久精品电影网 | 中文字幕一区二区三区人妻电影 | 性开放淫合集 | 水蜜桃av在线 | 国产一区二区麻豆 | 日韩欧美一区二区在线 | 91精品啪在线观看国产 | 亚洲精品成av人片天堂无码 | 操比网站 | 第一区免费在线观看 | 欧美性高潮 | 日韩欧美中文字幕在线播放 | 日本乱偷人妻中文字幕在线 | 偷拍网亚洲 | 国产精品一区二区入口九绯色 | 国产经典毛片 | a√国产| 日本午夜电影 | 久久av色| 亚洲无限av | 亚洲精品中字 | 国内91视频 | 高清一二三区 | 免费观看成人鲁鲁鲁鲁鲁视频 | 久久艹国产精品 | 中文字幕一区二区三区免费 | 中文字幕第一页av | 影音先锋每日资源 | 欧美一区二不卡视频 |