Day30:2026年2月20日打卡

一、上机打卡

1.1 字符串排序

1.1.1 题目

输入一行字符串,全部由小写字母构成,对字符串按26个英文字母的先后顺序进行排序,然后输出。

输入样例

asdf

shflsahfslfdjsldfsjd

输出样例

adfs

adddffffhhjjlllsssss

1.1.2 总结

读取一行字符串,赋值给名为s的字符串,调用algorithm库里面的sort函数即可实现字符串排序。

cpp 复制代码
sort(s.begin(), s.end());

1.1.3 代码

cpp 复制代码
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string s;
	while (getline(cin, s)) {
		sort(s.begin(), s.end());
		cout << s << endl;
	}
	return 0;
}

1.2 回文问题

1.2.1 题目

输入一串字符,其长度小于200,判断该串字符是否构成回文。 所谓回文是指从左到右和从右到左读一串字符的值是一样的,如:ABCBA。

输入样例

abcba

abcbb

输出样例

Yes

No

1.2.2 总结

读入字符串为s,创建s的副本s1,使用algorithm库里面的reverse函数即可实现字符串逆置。

cpp 复制代码
reverse(s.begin(), s.end());

判断s1与s是否相等,若相等即为回文

1.2.3 代码

cpp 复制代码
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string s;
	while (getline(cin, s)) {
		string s1 = s;
		reverse(s.begin(), s.end());
		if (s1 == s) cout << "Yes";
		else cout << "No";
		cout << endl;
	}
	return 0;
}

1.3 字符串中找整数

1.3.1 题目

对于一个字符串,编程找出其中的所有整数。例如,字符串"a12bc34d05",其中有整数12、34、5。

程序输入包括多行,每一行都是一串字符,字符串长度不超过500。字符串中的字符只有字母与数字。

程序输出为多行,每行第一个数代表所对应的字符串中整数的总个数。紧跟其后的依次是每个整数,数和数之间有一个空格。行与行之间没有多余空行,行首行尾没有多余空格。

输入样例

a12bc034d5

12886668&78711

abcdefghijklmn

输出样例

3 12 34 5

2 12886668 78711

0

1.3.2 总结

创建vector容器存取字符串s中出现的所有整数。

遍历s的每一个字符,若为数字,则读取该数字后的每一个数字,直到读取到数字即可。

创建num存储当前读到的数字,初始化为0,每读取到一位新的数字都令num = num * 10 + (s[i] - '0');

读取到非数字后,num存入容器中,并重新置为0。

1.3.3 代码

cpp 复制代码
#include <iostream>
#include <string>
#include <cctype>
#include <vector>
using namespace std;
void solve(string s) {
	vector <int> data;
	for (int i = 0; i < s.size(); i++) {
		if (isdigit(s[i])) {
			int num = 0;
			while (i < s.size() && isdigit(s[i])) {
				//num = 10 * num + s[i++];
				num = 10 * num + (s[i++] - '0');
			}
			data.push_back(num);
			i--;
		}
	}
	cout << data.size();
	for (const int& val : data) 
		cout << " " << val;
	cout << endl;
}
int main() {
	string s;
	while (getline(cin, s)) {
		solve(s);
	}
	return 0;
}

二、翻译打卡

P1

原文:

To return, then, to the switching capabilities of a modern computer: computers in the1970s were generally able to handle eights witches at a time. That is, they could deal with eight binary digits, or bits, of data, at every cycle. A group of eight bits is called a byte, each byte containing 256 possible patterns of ONs and OFFs (or 1s and 0s).Each pattern is the equivalent of an instruction, a part of an instruction, or a particular type of datum, such as a number or a character or a graphics symbol. The pattern 11010010, for example, might be binary data---in this case, the decimal number 210---or it might be an instruction telling the computer to compare data stored in its switches to data stored in a certain memory-chip location.

译文:

那么,回到现代计算机的切换能力上:20 世纪70 年代的计算机通常每次可以处理 8 个开关。也就是说,它们可以在每个周期内处理 8 个二进制数字,即位。8 位一组称为字节,每个字节包含256 种可能的打开和关闭(或 1s 和 0s)模式。每个模式都相当于一条指令、指令的一部分或特定数据类型,例如数字、字符或图形符号。例如,模式11010010 可能是二进制数据------在这种情况下,十进制数 210------也可能是指令,告诉计算机将存储在开关中的数据与存储在特定存储器芯片位置中的数据进行比较。

P2

原文:

The development of processors that can handle 16, 32, and 64 bits of data at a time has increased the speed of computers. The complete collection of recognizable patterns---the total list of operations---of which a computer is capable is called its instruction set. Both factors---the number of bits that can be handled at one time, and the size of instruction sets---continue to increase withthe on going development of modern digital comp

译文:

能够同时处理 16、32 和 64 位数据的处理器的发展提高了计算机的速度。计算机能够识别的模式的完整集合------操作的总列表------称为其指令集。这两个因素------一次可以处理的数据位数和指令集的大小------随着现代数字计算机的不断发展而继续增加。

P3

原文:

Modern digital computers are all conceptually similar, regardless of size. Nevertheless, they can be divided into several categories on the basis of cost and performance: the personal computer or microcomputer, a relatively low-cost machine, usually of desktop size (though "laptops" are small enough to fit in a briefcase, and "palmtops" can fit into a pocket); the workstation, a micro computer with enhanced graphics and communications capabilities that make it especially useful for office work; the mini computer, generally too expensive for personal use, with capabilitiess uited to a business, school, or laboratory;and the main frame computer, a large,expensive machine with the capability of serving the needs of major business enterprises, government departments,scientific research establishments, or the like(the largest and fastest of these are called supercomputers).

译文:

现代数字计算机在概念上都是相似的,无论其大小。然而,它们可以根据成本和性能分为几类:个人计算机或微型计算机,这是一种成本相对较 低、通常为台式机大小的机器(尽管"膝上型"计算机小到可以放在公文包里,而"掌上型"计算机小到可以放在口袋里)​;工作站,这是一种具有增强的图形和通信功能的微型计算机,这使得它对办公室工作特别有用;小型计算机,通常对于个人使用来说过于昂贵,其功能适合于商业、学校或实验室;主机计算机,这是一种大型、昂贵的计算机,其功能可以满足大型企业、政府部门、科研机构等的需求(其中最大、最快的计算机被称为超级计算机)​。

三、单词打卡

相关推荐
yu85939586 小时前
利用MATLAB进行木材图像去噪
开发语言·算法·matlab
cpp_25017 小时前
P2722 [USACO3.1] 总分 Score Inflation
数据结构·c++·算法·动态规划·题解·洛谷·背包dp
民乐团扒谱机7 小时前
【源码剖析】MATLAB混响函数底层逻辑拆解:Dattorro算法从公式到音频帧的完整推导
算法
淡海水7 小时前
【AI模型】概念-Token
人工智能·算法
凯瑟琳.奥古斯特7 小时前
数据结构核心知识点精要
数据结构·算法·排序算法
隔壁大炮7 小时前
Day02-04.张量点乘和矩阵乘法
人工智能·pytorch·深度学习·线性代数·算法·矩阵
王老师青少年编程7 小时前
csp信奥赛C++高频考点专项训练之贪心算法 --【删数问题】:删数问题
c++·算法·贪心·csp·信奥赛
geneculture7 小时前
本真信息观:基于序位守恒的融智学理论框架——人类认知第二次大飞跃的基础
人工智能·算法·机器学习·数据挖掘·融智学的重要应用·哲学与科学统一性·融智时代(杂志)
kronos.荒7 小时前
动态规划——最长递增子序列系列问题(python)
算法·动态规划·最长递增子序列系列问题
生信研究猿7 小时前
#P4625.第2题-大模型训练显存优化算法
算法