摘要:
在輸入的過程中,我們經常用回車來將數據分成不同的部分。那么,我們應該怎么來識別回車呢?這里有一個十分牛B的處理方法:那就是用gets(str)。為什么用gets呢?因為它能夠讀入回車,像scanf呀,cin呀都是不可以讀入回車的。那么怎么來判斷gets讀入的是不是回車呢?這里有一個牛B的處理方法:那就是用strcmp(str, "")==0;為什么呢是將str和“”來比較呢。因為只有一個回車獨占一行的話,這是的str是空的。好了,說了這么多,還是來總結一下吧。while(gets(str), strcmp(str, "")!=0){ ……;}用上面的這個
閱讀全文
摘要:
題目:http://acm.hdu.edu.cn/showproblem.php?pid=1251這個相當簡單就不解釋了。直接上代碼。View Code #include "iostream"#include "cstdio"#include "cstring"#include "string"using namespace std;typedef struct node{ int Cross; struct node *next[26];}node;node *head;void InitHead(){ head
閱讀全文
摘要:
題目:http://acm.swust.edu.cn/oj/problem/842/這個題目是有一點復雜的,因為在存儲內容的時候又再次用了鏈表。可以說它是鏈表題目的相當典型的例子了。還是直接上代碼吧。View Code #include "iostream"#include "cstring"#include "string"#include "cstdio"#include "algorithm"#include "malloc.h"using namespace std;
閱讀全文