程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> hdu 1241 Oil Deposits

hdu 1241 Oil Deposits

編輯:關於C++

 

//c++寫輸入時有問題

 

#include 
#include 
#include 
#include 

/*
map數組是用來裝字符的
n,m提高作用域,使訪問的權限變高
dir方便廣度優先搜索,因為要搜索8個方向,這樣做最方便
*/
char map[101][101];
int n,m;
int dir[8][2]={{-1,-1},{0,-1},{1,-1},{-1,0},{1,0},{-1,1},{0,1},{1,1}};

int main(){
    void breadthFirstSearch(int x,int y);
    bool isWithinMap(int x,int y);
    while(scanf("%d%d",&m,&n)!=EOF,n+m){
        /*
        m是行指標
        n是列指標
        */
        getchar();
        for(int i=0;i=m||y<0||y>=n){
        return false;
    }
    return true;
}


 

 

 

 

 

 

Oil Deposits

石油儲量
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 18046 Accepted Submission(s): 10399



Problem Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp地質調查公司負責檢測地下石油資源儲量。
GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. GeoSurvComp每次在一個大矩形區域中工作,創建一個網格,將土地劃分為許多方形耕地。
It then analyzes each plot separately, using sensing equipment to determine whether or not the plot contains oil. 然後分別分析每一個油井,使用傳感設備來確定該油井是否包含石油。
A plot containing oil is called a pocket. 一塊油井有油著稱為一塊油田。
If two pockets are adjacent, then they are part of the same oil deposit.
如果兩塊油田是相鄰的,且他們是相鄰的。 Oil deposits can be quite large and may contain numerous pockets. 石油資源可能很大,可能包含眾多的油井。
Your job is to determine how many different oil deposits are contained in a grid.
你的工作是確定有多少不同的油田被包含在一個網格。
Input The input file contains one or more grids. 輸入文件包含一個或多個網格。
Each grid begins with a line containing m and n, the number of rows and columns in the grid, separated by a single space. 每一個網格的第一行,分別是m和n,表示網格是m行n列,每兩個數字用一個空格隔開。 If m = 0 it signals the end of the input; otherwise 1 <= m <= 100 and 1 <= n <= 100. 如果m=0著輸入結束否著1 <= m <= 100 and 1 <= n <= 100。 Following this are m lines of n characters each (not counting the end-of-line characters). 每一行有n個字符(不包括回車符); Each character corresponds to one plot, and is either `*', representing the absence of oil, or `@', representing an oil pocket.
每一個字符都要相對應的油田,“*”表示沒有油井,“@”表示一個油井。
Output For each grid, output the number of distinct oil deposits. 對於每一個網格,輸出不同的石油資源的數量。
Two different pockets are part of the same oil deposit 對於不同的油井, if they are adjacent horizontally, vertically, or diagonally. 如果在水平,垂直,斜角是相鄰的,那麼表示兩個油井是一片油田。
An oil deposit will not contain more than 100 pockets.
一塊油田最多包含100塊油井。
Sample Input
1 1
*
3 5
*@*@*
**@**
*@*@*
1 8
@@****@*
5 5 
****@
*@@*@
*@**@
@@@*@
@@**@
0 0 

Sample Output
0
1
2
2

Source Mid-Central USA 1997

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved