【day24】

题目:

从键盘上输入一个整数N,按以下规律输出一个(2N+1)*(2N+1)的矩阵:

对角线的值为1,

上半三角区域值为2,

下半三角区域值为3,

左半三角区域的值为4,

右半三角区域的值为5。

个人总结:

  1. 按上下两部分进行输出
  2. 注意格式要求!!
cpp 复制代码
#include<iostream>
using namespace std;
int main() {
	int n;
	while (cin >> n) {
		int m = 2 * n + 1;
		for (int i = 1; i <= m/2+1; i++) {//上半部分
			for (int j = 1; j < i; j++) {
				cout << 4 << " ";
			}
			cout << 1 << " ";
			for (int k = 1; k <= m-i*2; k++) {
				cout << 2 << " ";
			}
			if (i != m / 2 + 1) {
				cout << 1;
				if (i != 1) {
					cout << " ";
				}
			}
			for (int h = 1; h < i; h++) {
				cout << 5 ;
				if (h != i - 1)cout << " ";
			}
			cout << endl;
		}
		for (int i = 1; i < m / 2 + 1; i++) {//下半部分
			for (int j = 1; j < m / 2 + 1-i; j++) {
				cout << 4 << " ";
			}

			cout << 1 <<" ";
			for (int k = 1; k <= 2*i-1; k++) {
				cout << 3 << " ";
			}

			cout <<1;
			if (i != m / 2)cout << " ";
			for (int h = 1; h < m / 2 + 1 - i; h++) {
				cout << 5;
				if (h != m / 2 - i)cout << " ";
			}
			cout << endl;
		}
	}
	return 0;
}

题目:

编制一个模拟发牌的程序。有编号为1,2,3,4四个人,将一付去掉大小怪的扑克按照如下顺序排列梅花c0-c12,方块d0-d12,红桃h0--h12,黑桃s0-s12,然后按照1,2,3,4四个人的顺序发牌,问最后每个人手上的牌有哪些。

个人总结:

  1. 根据输入的人物编号,决定各形状牌的数量
  2. 因为总共只有4的人,13张牌循环,所以隔4张牌取模13
cpp 复制代码
#include<iostream>
using namespace std;
int main() {
	char a[4] = { 'c','d','h','s' };
	int n;
	while (cin >> n) {
		int p=n-1;
		int b[4] = { 3,3,3,3 };
		b[p] = 4;
		int cnt = 0;
		int j = 0;
		for (int i = 0; i < 13; i++) {
			if (cnt == b[j]) {
				j++;
				cnt = 0;
			}
			cnt++;
			cout << a[j] << " " << p;
			if (i != 12)cout << " ";
			p = (p + 4) % 13;
		}
		cout << endl;
	}
	return 0;
}

题目:

考虑在下面被显示的数字金字塔(第n行有n列)。写一个程序来计算从最高点开始在底部任意处结束的路径经过数字的和的最大。每前进一步可以走到它的正下方或者右下方(往下一行、往右一列)的位置。

7

3 8

8 1 0

2 7 4 4

4 5 2 6 5

在上面的样例中,从7 到 3 到 8 到 7 到 5 的路径产生了最大和:30

个人总结:

  1. 使用递归,计算下一步可取到的最大值,注意m要加上a[x][y]累加结果
  2. 递归函数当在最后一行时,返回当前数组值(在上一行中已经比较出最大)
cpp 复制代码
#include<iostream>
using namespace std;
int a[1000][1000];
int r;
int maxqiu(int x,int y) {
	if (x == r - 1) {
		return a[x][y];
	}
	int m = a[x][y]+max(maxqiu(x + 1, y), maxqiu(x + 1, y + 1));
	return m;
}
int main() {
	cin >> r;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j <= i; j++) {
			cin >> a[i][j];
		}
	}
	cout << maxqiu(0,0)<< endl;
	return 0;

}

Translation:

The GPS was developed in 1973 by the U. S. Air Force. Similar developments have also occurred in the European Union, Russia, and China. Since 1994, a degraded GPS has been made availablefor civilian applications in providing reliable positioning,navigation, and timing services. For anyone with a GPS receiver,the system will provide accurate location and time informationfor an unlimited number of users in all weather conditions, dayand night, anywhere in the world.

全球定位系统(GPS)于 1973 年由美国空军研发。欧盟、俄罗斯和中国也有类似的研发成果。自 1994 年起,性能有所降低的 GPS 开始应用于民用领域,提供可靠的定位、导航和授时服务。任何拥有 GPS 接收器的人,无论在世界任何地方、任何天气条件下,无论白天黑夜,该系统都能为无限数量的用户提供精确的位置和时间信息。

Synergistic technologies play supporting roles. For example,biometrics could be widely applied to personalize the interactions among humans, machines, and objects. Artificialintelligence, computer vision, robotics, and telepresence canmake our lives more automated in the future.

协同技术发挥着辅助作用。例如,生物识别技术可广泛应用于实现人类、机器与物体之间的个性化交互。人工智能、计算机视觉、机器人技术和远程呈现技术有望在未来让我们的生活更加自动化。

  • synergistic technologies 协同技术
  • supporting roles 辅助功能
  • biometrics 生物识别技术

As an emerging technology, the IoT will become more matureand more sophisticated. Figure 12C-1 shows the majortechnology advances and key applications that may benefit from the IoT. For example, supply chains are now better supported than before. Vertical market applications may represent the next wave of advances. Ubiquitous positioning is expected to becomea reality as we move toward 2020. Beyond that, a physical IoT may be in place in a global scale. These advances will significantly upgrade human abilities, societal outcomes,national productivity, and quality of life.

作为一项新兴技术,物联网(IoT)将变得更加成熟和复杂。图 12C-1 展示了可能从物联网中受益的主要技术进步和关键应用。例如,供应链如今得到了比以往更好的支持。垂直市场应用可能代表着下一波进步浪潮。随着我们迈向 2020 年,无处不在的定位有望成为现实。在此之后,实体物联网可能会在全球范围内建成。这些进步将显著提升人类能力、社会成果、国家生产力和生活质量。


相关推荐
徐小夕1 小时前
pxcharts Ultra V2.3更新:多维表一键导出 PDF,渲染兼容性拉满!
vue.js·算法·github
CoovallyAIHub2 小时前
OpenClaw一脚踩碎传统CV?机器终于不再只是看世界
深度学习·算法·计算机视觉
CoovallyAIHub2 小时前
仅凭单目相机实现3D锥桶定位?UNet-RKNet破解自动驾驶锥桶检测难题
深度学习·算法·计算机视觉
zone77392 小时前
002:RAG 入门-LangChain 读取文本
后端·算法·面试
樱木Plus3 小时前
深拷贝(Deep Copy)和浅拷贝(Shallow Copy)
c++
得物技术3 小时前
得物社区搜推公式融合调参框架-加乘树3.0实战
算法
会员源码网1 天前
使用`mysql_*`废弃函数(PHP7+完全移除,导致代码无法运行)
后端·算法
木心月转码ing1 天前
Hot100-Day10-T438T438找到字符串中所有字母异位词
算法
HelloReader1 天前
Wi-Fi CSI 感知技术用无线信号“看见“室内的人
算法
颜酱1 天前
二叉树分解问题思路解题模式
javascript·后端·算法