洛谷P1187 3D模型

2022-06-28 18:41:41 浏览数 (1)

本文最后更新于 1170 天前,其中的信息可能已经有所发展或是发生改变。

代码语言:javascript复制
// 洛谷P1187 3D模型.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include<iostream>
using namespace std;
void test1(int ***p,int n,int m)
{
	int i, j, k,sum=0;
	for (i = 0; i < n; i  )
	{
		for (j = 0; j < m; j  )
		{
			for (k = 0; k < 10; k  )
			{
				
				cout << p[i][j][k]<<" ";
			}
			cout << "   ";
		}
		cout << endl;
	}
}
int sum(int n, int m, int ***p)
{
	int sum = 0,i,j,k;
	for (i = 0; i < n; i  )
	{
		
		for (j = 0; j < m; j  )
		{

			for (k = 0; k < 10; k  )
			{
				if (p[i][j][k] == 1)
				{

					if (p[i][j][k   1] == 0)
					{
						sum  ;
					}
					if (i == 0)
					{
						sum  ;
					}
					else
					{
						if (p[i - 1][j][k] == 0)
							sum  ;
					}
					if (j == 0)
					{
						sum  ;
					}
					else
					{
						if (p[i][j - 1][k] == 0)
							sum  ;
					}
					if (i == n - 1)
						sum  ;
					else
					{
						if (p[i   1][j][k] == 0)
							sum  ;
					}
					if (j == m - 1)
						sum  ;
					else
					{
						if (p[i][j 1][k] == 0)
							sum  ;
					}
					if (k == 0)
						sum  ;
					

				}
				

			}
		}
	}
	return sum;
}
int main()
{
	int i, j,k, m, n;
	cin>>n >> m;
	int ***p = new int **[n];
	for (i = 0; i < n; i  )
	{
		p[i] = new int *[m];
		for (j = 0; j < m; j  )
		{
			p[i][j] = new int[10];
		}
	}
	for (i = 0; i < n; i  )
	{
		//char a1;
		//cin >> a1;
		char *str=new char[m];
		//str = a1;
		
		for (i = 0; i < n; i  )
		{
			cin >> str;
			for (j = 0; j < m; j  )
			{
				
				for (k = 0; k < 10; k  )
				{
					if (k < int(str[j]-'0'))
					{
						p[i][j][k] = 1;
					}
					else
					{
						p[i][j][k] = 0;
					}
					
				}
			}
		}
		

	}
	cout << sum(n, m, p);
	//test1(p, n, m);
	return 0;
}

Post Views: 234

0 人点赞