原poj 2713(基础题)
来源:互联网 发布:百衲本二十四史 知乎 编辑:程序博客网 时间:2024/06/04 18:45
计算区域内像素点个数
vector<vector<int> > 必须在>和>之间空一个格
未分配区域前不能下表访问vector
#include <iostream>#include <fstream>#include <string>#include <algorithm>#include <vector>using namespace std;#define _debbug//全局数据int main(){//重定向#ifdef _debbugstreambuf *backup1;ifstream fin;fin.open ("F:\\input.txt" ,ios::in );backup1 = cin.rdbuf() ; // back up cin's streambufcin.rdbuf( fin.rdbuf() ) ; // assign file's streambuf to cin#endif //vector<vector<int> > graph1 ;int n ;int i,j ;cin >> n ;graph1.resize(n) ;for (i = 0 ; i < n ; ++i){graph1[i].resize(n) ;for (j = 0 ; j < n ; ++j){int val ;cin >> val ;graph1[i][j] = val ;}}int leftx,lefty,rightx,righty,flag = 0;for (i = 0 ; i < n ; ++i){if (flag == 1)break;for (j = 0 ; j < n ; ++j){if (graph1[i][j] == 255)continue ;else{leftx = j ;lefty = i ;flag = 1;break ;}}}for (i = lefty ,j = leftx ; i < n ; ++i){if (graph1[i][j] == 0)continue ;else break ;}if (i < n)rightx = i - 1 ;elserightx = n - 1 ;for (i = lefty ,j = rightx ; j < n ; ++j){if (graph1[i][j] == 0)continue ;else break ;}if (j < n)righty = j - 1 ;elserighty = n - 1 ;cout << (rightx - leftx - 1) * (righty - lefty - 1) << endl ;//解除重定向关闭文件#ifdef _debbugcin.rdbuf(backup1) ; // restore cin's original streambuffin.close();#endifreturn 0 ;}
- 原poj 2713(基础题)
- 原poj 2714(基础题)
- 原poj 2767 (基础题)
- 原poj 2680(基础题)
- 原 poj 2796(基础题)
- 原 poj 2715(基础题) 奖学金
- 原 poj2677(基础题)
- 原根 poj 1284
- poj 1284 原根
- 原根 poj 1284
- 基础:PV原语
- Java原基础
- poj 基础入门题
- 原根小结 (poj 1284)
- 原码反码补码基础
- 原码反码补码基础
- [基础]原码反码补码
- poj 1273(dinic....基础题)
- linux下安装与卸载mysql
- 在安装的过程中参考了这位博主的帖子
- Oracle Hints
- Linux Platform Device and Driver
- 老板为什么会被下属“反领导”
- 原poj 2713(基础题)
- Window获取当前目录路径心得
- 中小企业非正常致死的三支“冷箭”
- can not find -lXXX
- NoSQL,未来数据库的趋势
- wpf 自定义Tooltip template
- android开发中遇到的一些问题
- Ecplise的一些快捷键
- shell 遍历数组