58. 素数表

题目

问题描述

从键盘输入m,n

在屏幕上按每行10个的格式输出m~n之间的全部素数。

请用函数判断一个数是否素数。

输入说明

两个整数m n

输出说明

[m,n]之间(包含m和n)的素数,每行10个,每个数后跟一个空格。

个人总结

思路

素数的定义:

一个大于1的自然数,除了1和它本身外,不能被其他自然数整除(即因数只有1和本身)。

易错点
  1. 注意输出每 10 个数要换行
  2. 判断素数时因子至少要算到根号,即 i <= root ,需要有等于号
  3. 不要忘记 1 也是素数,需要特判

代码

#include <bits/stdc++.h>
using namespace std;

bool is_prime(int n) {
	// 1 不是素数
	if (n == 1) return false;
	// 2 是素数
	if (n == 2) return true;
	
	// 只算到根号
	int r = sqrt(n);
	for (int i = 2; i <= r; i++) {
		if (n % i == 0) return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int m,n;
	cin >> m >> n;
	
	int cnt = 0;
	for (int i = m; i <= n; i++) {
		if (is_prime(i)) {
			cnt++;
			cout << i << " ";
			if (cnt % 10 == 0) {
				cout << "\n";
			}
		}
	}
	
	
	return 0;
}

59. 倒数数列

题目

问题描述

编写程序计算并输出

s=sumk=1n (1/k) = 1+1/2+1/3+............+1/n 的值。

要求定义并调用函数total(n)计算1+1/2+1/3+......+1/n

注意:此题的main函数如下所示:
 

int main(){

 int n;

 scanf("%d",&n);

 printf("%.3f\n",total(n));

 return 0;

}

或者:

int main(){

 int n;

 cin>>n;

 cout<<fixed<<setprecision(3)<<total(n)<<endl;

 return 0;

}

输入说明

正整数n,表示前n项求和

输出说明

s,表示前n项的和

首尾无空格

个人总结

易错点
  1. 变量类型要用 double
  2. 分母是 i ,不是 n
  3. 1 / i 得到的是整数,1.0 / i 得到的才是小数

代码

#include <bits/stdc++.h>
using namespace std;

double total (int n) {
	double sum = 0;
	for(int i = 1; i <= n; i++) {
		sum += 1.0 / i;
	}
	return sum;
}

int main(){

 int n;

 cin>>n;

 cout<<fixed<<setprecision(3)<<total(n)<<endl;

 return 0;

}

60. 排列数

题目

问题描述

编写程序计算排列数

Pmn =m! / (m-n)!

要求定义函数fact(n)计算n的阶乘。

main函数中可使用如下形式调用:fact(m)/fact(m-n));
 

输入说明

两个数m、n

输出说明

Pmn

输入范例

3 2

输出范例

6
 

个人总结

易错点

阶乘的时候要包括数字本身

代码

#include <bits/stdc++.h>
using namespace std;

long long fact(int num) {
	long long f = 1;
	for (int i = 1; i <= num; i++) {
		f *= i;
	}
	return f;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int m, n;
	cin >> m >> n;
	
	long long res = fact(m)/fact(m-n);
	cout << res;
	
	return 0;
}

计算机英语翻译练习

AR can also be helpful for a sales person who is trying to demonstrate the virtues of a product. Especially for complex devices, it may be difficult to convey the internal operation with words alone. Letting a potential customer observe the animated interior allows for much more compelling presentations at trade shows and in show rooms alike.

对于试图展现产品优势的销售人员来说,AR 也大有用处。

尤其是对于复杂的设备来说,仅仅使用言语来传达其内部运行原理相当困难。

在交易展或者展厅这样的地方,让潜在消费者观察内部构造动画,会让展示有说服力得多。

Pictofit  is a virtual dressing room application that lets users preview garments from online fashion stores on their own body (Figure 12B-4). The garments are automatically adjusted to match the wearer's size. In addition, body measurements are estimated and made available to assist in the entry of purchase data.

Pictofit 是一款虚拟试衣间应用,它让用户可以预览网上时装商店的服装穿在自己身上的样子(图 12B-4)

服装会自动调整以适应穿着者的身材。

此外,用户的身材数据也会得到评估,并提供这些数据以辅助购买数据的录入。

In 2005, the concept of the Internet of Things (loT) entered the limelight. The loT should be designed to connect the world's objects in a sensory manner. The approach is to tag things through radio-frequency identification (RFID), feel things through sensors and wireless networks, and think things by building embedded systems that interact with human activities.

2005 年,物联网的概念进入公众视野。物联网旨在以感知的方式来连接世间万物。

其实现路径是通过射频识别(RFID)标识物体,通过传感器和无线网络来感知事物,并借助与人类活动交互的嵌入式系统使物体实现思考。

背单词打卡截图

Logo

openvela 操作系统专为 AIoT 领域量身定制,以轻量化、标准兼容、安全性和高度可扩展性为核心特点。openvela 以其卓越的技术优势,已成为众多物联网设备和 AI 硬件的技术首选,涵盖了智能手表、运动手环、智能音箱、耳机、智能家居设备以及机器人等多个领域。

更多推荐