2.19列阵,私聊调配,求小数位数个数

1.题目:

明明在上学的时候,参加数学兴趣班。在班上,老师介绍了一种非常有趣的阵列。

该阵列由n个正整数构成,阵列中的数字从1开始递增,数字的排序规则是从1开始由中间逆时针向外转出,2出现在1的下面,然后直至输出n为止。

例如当n=5的时候,阵列如下:

5

1 4

2 3

当n=9时,阵列如下:

7 6 5

8 1 4

9 2 3

当n=10时,阵列如下:

7 6 5

8 1 4

9 2 3

10

明明回家后想自己动手构造这样的阵列。他从n=1开始构造,但是他发现当n越来越大时,阵列的复杂性就越高,然后构造出来的阵列就越容易出错。为了降低构造阵列的出错率,提高构造速度,明明就求助于你,请你帮他写一个程序,来构造这样的阵列。

明明的问题可以归结为:给你一个正整数n,请你按题目描述中所述的方法,构造出阵列。

输入:

5

45

10

输出:

5

1 4

2 3

43 42 41 40 39 38 37

44 21 20 19 18 17 36

45 22 7 6 5 16 35

23 8 1 4 15 34

24 9 2 3 14 33

25 10 11 12 13 32

26 27 28 29 30 31

7 6 5

8 1 4

9 2 3

10
个人心得:

暂时没搞懂

2.题目:

农夫约翰从来只用调配得最好的饲料来为他的奶牛。

饲料用三种原料调配成:大麦,燕麦和小麦。他知道自己的饲料精确的配比,在市场上是买不到这样的饲料的。他只好购买其他三种混合饲料(同样都由三种麦子组成),然后将它们混合,来调配他的完美饲料。

给出三组整数,表示 大麦:燕麦:小麦 的比例,找出用这三种饲料调配 x:y:z 的饲料的方法。

例如,给出目标饲料 3:4:5 和三种饲料的比例:

1:2:3

3:7:1

2:1:2

你必须编程找出使这三种饲料用量最少的方案,要是不能用这三种饲料调配目标饲料,输出'NONE'。'用量最少'意味着三种饲料的用量(整数)的和必须最小。

对于上面的例子,你可以用8份饲料1,2份饲料2,和5份饲料3,来得到7份目标饲料: 8*(1:2:3) + 1*(3:7:1) + 5*(2:1:2) = (21:28:35) = 7*(3:4:5)

以上数字中,表示饲料比例的整数都是小于100(数量级)的非负整数,表示各种饲料的份数的整数都小于100。一种混合物的比例不会由其他混合物的比例直接相加得到。

输入:

3 4 5

1 2 3

3 7 1

2 1 2

输出:8 1 5 7

个人心得:

1.将输入的数放入二维数组当中,用一个三层循环遍历找到让等式成立的ijkl就跳出

复制代码
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int x, y, z;
	scanf("%d %d %d", &x, &y, &z);
	int a[3][3] = { 0 };
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			scanf("%d", &a[i][j]);
		}
	}
	bool stop = false;
	for (int i = 0; i < 100; ++i) {
		for (int j = 0; j < 100; ++j) {
			for (int k = 0; k < 100; ++k) {
				int num1, num2, num3;
				num1 = i * a[0][0] + j * a[1][0] + k * a[2][0];
				num2= i * a[0][1] + j * a[1][1] + k * a[2][1];
				num3 = i * a[0][2] + j * a[1][2] + k * a[2][2];
				for (int l = 1; l < 100; ++l) {
					if (num1 == l * x && num2 == l * y && num3 == l * z) {
						printf("%d %d %d %d", i, j, k, l);
						stop = true;
						break;
					}
				}
				if (stop) {
					break;
				}
			}
			if (stop) {
				break;
			}
		}
		if (stop) {
			break;
		}
	}
	if (!stop) {
		printf("NONE");
	}
}

3.题目:

明明最近在一家软件公司实习,公司分配给他一个任务,要他写一个小程序,这个程序的功能是求出一个浮点数的小数部分的长度。例如程序输入1.1,则输出1,程序输入1.11,则输出2,明明觉得这个非常简单,花了不到5分钟的时间就把程序给写出来了,然后就把程序交给了测试员测试。但是没有想到的是,经过测试员的测试,发现了一大堆的错误,返回的结果很多都是不对的,这个令明明相当的不解,始终想不通自己的程序错在哪里。你是一名经验丰富的程序员,明明把这个问题来求助于你,明明和你说了他的想法,你一听就明白明明错在了哪里,原来明明使用double型来存放浮点数,但是由于double型的精度问题,不可能把所有的小数都精确的保存好,如果小数位数很长,就会出错。你发现了问题。现在请你写出正确的程序。 明明的问题可以归结为:给你一个浮点数,请你求出这个浮点数的小数位数。

输入:

1.11

1.00000000000000001

输出:

2

17

个人心得:

1.将输入的数字拆分放入字符数组当中,计算小数点后面的个数即可

复制代码
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
	char a[101];
	while (scanf("%99s", a)==1) {
		
		int sum = 0;
		int j = -1;
		for (int i = 0; a[i] != '\0'; ++i) {
			if (a[i] == '.') {
				j = i;
				break;
			}
		}
		if (j != -1) {
			for (int i = j + 1; a[i] != '\0'; ++i) {
				sum++;
			}
		}
		printf("%d\n", sum);
	}
}

第一段:

4.Robotics

Another area of computer science that has found wide practical use is robotics---the design and development of computer controlled mechanical devices. Robots range in complexity from toys to automated factory assembly lines, and relieve humans from tedious, repetitive, or dangerous tasks. Robots are also employed where requirements of speed, precision, consistency, or cleanliness exceed what humans can accomplish. Roboticists---scientists involved in the field of robotics---study the many aspects of controlling robots. These aspects include modeling the robot's physical properties, modeling its environment, planning its actions, directing its mechanisms efficiently, using sensors to provide feedback to the controlling program, and ensuring the safety of its behavior. They also study ways of simplifying the creation of control programs. One area of research seeks to provide robots with more of the dexterity and adaptability of humans, and is closely associated with AI.

翻译:

4.机器人学

计算机科学的另一个已广泛应用于实际领域的分支是机器人学------即由计算机控制的机械装置的设计与开发。机器人的复杂程度不一,从玩具到自动化工厂装配线都有,它们能够使人类摆脱那些单调、重复或危险的工作。在对速度、精度、一致性或洁净度的要求超出人类能力的场合,机器人也会被使用。机器人学家------从事机器人领域研究的科学家------研究控制机器人的诸多方面。这些方面包括对机器人物理特性的建模、对其环境的建模、规划其行动、高效地控制其机械装置、利用传感器为控制程序提供反馈,以及确保其行为的安全性。他们还研究如何简化控制程序的编写。其中一个研究方向是使机器人具备更多类似人类的灵巧性和适应能力,这一方向与人工智能密切相关。

第二段:

5.Human-Computer Interfacing

Human-computer interfaces provide the means for people to use computers. An example of a human-computer interface is the keyboard, which lets humans enter commands into a computer and enter text into a specific application. The diversity of research into human-computer interfacing corresponds to the diversity of computer users and applications. However, a unifying theme is the development of better interfaces and experimental evaluation of their effectiveness. Examples include improving computer access for people with disabilities, simplifying program use, developing three-dimensional input and output devices for virtual reality, improving handwriting and speech recognition, and developing head-up displays for aircraft instruments in which critical information such as speed, altitude, and heading are displayed on a screen in front of the pilot's window. One area of research, called visualization, is concerned with graphically presenting large amounts of data so that people can comprehend its key properties.

翻译:

5.人机交互

人机接口为人们使用计算机提供了手段。人机接口的一个例子是键盘,它使人们能够向计算机输入命令,并在特定应用程序中输入文本。人机交互研究的多样性与计算机用户和应用程序的多样性相对应。然而,一个统一的主题是开发更好的界面,并通过实验对其有效性进行评估。相关例子包括:为残障人士改善计算机的可访问性、简化程序的使用、为虚拟现实开发三维输入与输出设备、改进手写识别和语音识别,以及为飞机仪表开发平视显示器,使速度、高度和航向等关键信息显示在飞行员前方窗口前的屏幕上。另一个称为"可视化"的研究领域,致力于以图形方式呈现大量数据,使人们能够理解其关键特征。

第三段:

V. Connection of Computer Science to Other Disciplines

Theoretical computer science draws many of its approaches from mathematics and logic. Research in numerical computation overlaps with mathematics research in numerical analysis. Computer architects work closely with the electrical engineers who design the circuits of a computer.

翻译:

V. 计算机科学与其他学科的联系

理论计算机科学的许多方法来源于数学和逻辑学。数值计算方面的研究与数学中的数值分析研究相互交叉、相互重叠。计算机体系结构设计人员与负责设计计算机电路的电气工程师密切合作。

相关推荐
weixin_477271692 小时前
马王堆帛书《周易》六十四貞如何读象(《函谷门》原创)
算法·图搜索算法
追随者永远是胜利者10 小时前
(LeetCode-Hot100)53. 最大子数组和
java·算法·leetcode·职场和发展·go
生成论实验室10 小时前
即事经:一种基于生成论的宇宙、生命与文明新范式
人工智能·科技·神经网络·算法·信息与通信
王老师青少年编程11 小时前
csp信奥赛c++高频考点假期集训(分模块进阶)
数据结构·c++·算法·csp·高频考点·信奥赛·集训
癫狂的兔子12 小时前
【Python】【机器学习】K-MEANS算法
算法·机器学习·kmeans
Bear on Toilet13 小时前
递归_二叉树_50 . 从前序与中序遍历序列构造二叉树
数据结构·算法·leetcode·深度优先·递归
plus4s13 小时前
2月18日(82-84题)
c++·算法·动态规划
艾醒14 小时前
打破信息差——2026年2月19日AI热点新闻速览
算法
追随者永远是胜利者15 小时前
(LeetCode-Hot100)62. 不同路径
java·算法·leetcode·职场和发展·go