【day29】

题目:

大家都知道,手机号是一个11位长的数字串,同时,作为学生,还可以申请加入校园网,如果加入成功,你将另外拥有一个短号。假设所有的短号都是"6"+手机号的后5位,比如号码为13512345678的手机,对应的短号就是645678。

现在,如果给你一个11位长的手机号码,你能找出对应的短号吗?

cpp 复制代码
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	cin >> n;
	while (n > 0) {
		n--;
		string a;
		cin >> a;
		cout << 6;
		for (int i = 6; i < 11; i++) {
			cout << a[i];
		}
		cout << endl;
	}
	return 0;
}

题目:

对于给定的一个字符串,统计其中小写字母出现的次数。

cpp 复制代码
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	cin >> n;
	while (n > 0) {
		n--;
		string a;
		cin >> a;
		int cnt = 0;
		for (char c : a) {
			if (c >= 'a' && c <= 'z') {
				cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

题目:

你的弟弟刚做完了"100以内数的加减法"这部分的作业,请你帮他检查一下。每道题目(包括弟弟的答案)的格式为a+b=c或者a-b=c,其中a和b是作业中给出的,均为不超过100的非负整数;c是弟弟算出的答案,可能是不超过200的非负整数,也可能是单个字符"?",表示他不会算。

cpp 复制代码
#include<iostream>
#include<string>
using namespace std;

bool judge(string a) {//a+b=c
	int k = 0;
	int j = 0;
	int op = -1, ans = 0, o = 0;
	for (char c : a) {
		if (c<='9'&&c>='0') {
			if (op == -1)k = (int)(c - 48) + k * 10;//a
			if (op >= 0 && op < 3)j = (int)(c - 48) + j * 10;//b
			if (c == '?')return false;
			if (op == 3)o = (int)(c - 48) + o * 10;//c		
		}
		else if (c == '+') {
			op = 0;
		}
		else if (c == '-') {
			op = 1;
		}
		else if (c == '=') {
			if (op) {
				ans = k - j;
			}
			else ans = k + j;
			op = 3;
		}
	}
	return o == ans ? true : false;
}
int main() {

	int cnt = 0;
	string a;
	while (getline(cin, a)) {
		if (a.empty())break;//输入是空行则退出循环
		if (judge(a))cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Translation:

Analogue computers began to be built in the late 19th century.Early models calculated by means of rotating shafts and gears.Numerical approximations of equations too difficult to solve in any other way were evaluated with such machines. Lord Kelvin built a mechanical tide predictor that was a specialized analoguecomputer. During World Wars I and II, mechanical and, later,electrical analogue computing systems were used as torpedocourse predictors in submarines and as bombsight controllers in aircraft. Another system was designed to predict spring floodsin the Mississippi River basin.

模拟计算机创建于19世纪末。早期的模型通过旋转轴和齿轮来运算。很难用其他方法解出方程数值近似值,这问题可以用这计算机计算。 Lord Kelvin建造了一个机械潮汐预测器,它是一台特制的模拟计算机。在第一、二次世界大战期间,机械和之后的电力模拟计算机系统被用作鱼雷航向预测器来检测潜水艇,以及作为飞机上的轰炸瞄准器控制器。另一个系统被设计旨在预测密西西比河流域的春季洪水。

  • Analogue computers 模拟计算机
  • approximation 近似值
  • torpedocourse 鱼雷航向预测器
  • bombsight controllers 轰炸瞄准器控制器

During World War II, a team of scientists and mathematicians,working at Bletchley Park, north of London, created one of thefirst all-electronic digital computers: Colossus . By December1943, Colossus, which incorporated 1,500 vacuum tubes, was operational. It was used by the team headed by Alan Turing ,in the largely successful attempt to crack German radio messages enciphered in the Enigma code .

在第二次世界大战期间,由工作在伦敦北部布莱切利园的科学家和数学家组成的队伍创建了第一台全电力数字计算机之一:巨人计算机。到1943年12月,巨人计算机,包含1500个真空管,运行起来了。由爱兰图灵带领的团队使用它,极大成功地尝试破解了用恩尼格玛密码加密的德国电报。

  • vacuum tube 真空管
  • crack 打破,破解
  • encipher 加密

Independently of this, in the United States, a prototype electronic machine had been built as early as 1939, by JohnAtanasoff and Clifford Berry at Iowa State College. Thisprototype and later research were completed quietly and later overshadowed by the development of the Electronic Numerical Integrator And Computer (ENIAC) in 1945. ENIAC was granted a patent, which was overturned decades later, in 1973,when the machine was revealed to have incorporated principles first used in the Atanasoff-Berry Computer.

除了这个,在美国,一台原型店里机器同样在1939年,由在爱荷华州立学院的JohnAtanasoff和Clifford Berry创造出来。这台原型和之后的研究悄无声息地完成,之后被电子数字积分计算机在1945年的发展所掩盖。ENIAC被授予了专利,但在1973年十几年之后这项专利被推翻了,当这台机器被揭露包含了第一次被用于 Atanasoff-Berry计算机的原理。

  • integrator 积分

相关推荐
ALex_zry1 天前
C++网络编程心跳机制与连接保活:长连接稳定性保障
开发语言·网络·c++
学嵌入式的小杨同学1 天前
STM32 进阶封神之路(三十二):SPI 通信深度实战 —— 硬件 SPI 驱动 W25Q64 闪存(底层时序 + 寄存器配置 + 读写封装)
c++·stm32·单片机·嵌入式硬件·mcu·架构·硬件架构
米粒11 天前
力扣算法刷题 Day 27
算法·leetcode·职场和发展
好大哥呀1 天前
C++ Web 编程
开发语言·前端·c++
Fuxiao___1 天前
C 语言核心知识点讲义(循环 + 函数篇)
算法·c#
Mr_Xuhhh1 天前
LeetCode hot 100(C++版本)(上)
c++·leetcode·哈希算法
漫随流水1 天前
c++编程:反转字符串(leetcode344)
数据结构·c++·算法
南境十里·墨染春水1 天前
C++ 笔记 友元(面向对象)
开发语言·c++·笔记
C++ 老炮儿的技术栈1 天前
分享一个安全的CString
c语言·c++·windows·git·安全·visual studio
穿条秋裤到处跑1 天前
每日一道leetcode(2026.03.31):字典序最小的生成字符串
算法·leetcode