进阶7:
最近FJ为他的奶牛们开设了数学分析课,FJ知道若要学好这门课,必须有一个好的三角函数基本功。所以他准备和奶牛们做一个"Sine之舞"的游戏,寓教于乐,提高奶牛们的计算能力。
不妨设
An=sin(1+sin(2-sin(3+sin(4-...sin(n))...)
Sn=(...(A1+n)A2+n-1)A3+...+2)An+1
FJ想让奶牛们计算Sn的值,请你帮助FJ打印出Sn的完整表达式,以方便奶牛们做题。
个人总结:
- 注意括号的数量
cpp
#include<iostream>
#include<string.h>
using namespace std;
string itos(int n) {
string s = "";
while (n) {
int temp = n % 10;
s = (char)(temp + '0')+s;
n /= 10;
}
return s;
}
string an(int n) {
if (n == 1)return "sin(1)";
char op;
if ((n - 1) % 2 == 0)op = '-';
else op = '+';
string former = an(n - 1);
string b = "";
for (int i = 0; i < n; i++)b += ")";//括号也要增加
return former.substr(0, former.size() - n+1) + op + "sin(" + itos(n) + b;//将An-1最后两个右括号去掉,再加新字符串
}
string sn(int add, int k, int n) {
if (k == n) {
return an(k) + "+" + itos(add);
}
string b = "";
if (k == 1) {
for (int i = 0; i < n - 1; i++) b += "(";
}
return b + an(k) + "+" + itos(add) + ")" + sn(add - 1, k + 1, n);
}
int main() {
int n;
cin >> n;
cout << sn(n,1,n) << endl;
return 0;
}
ROM (read-only memory) contains a small set of instructionsand data called the boot loader. The boot loader instructions tell a digital device how to start. Typically, the boot loader performs self-tests to find out if the hardware is operating properly andmay also verify that essential programs have not been corrupted.It then loads the operating system into RAM. Whereas RAM istemporary and volatile, ROM is more permanent and non-volatile. The contents of ROM remain in place even when thedevice is turned off.
ROM只读存储器存储了引导加载程序的一系列指令和数据。引导加载指令告诉数字设备如何启动。引导加载程序执行自我检测,检查硬件是否在正确运行以及确保基础程序没有被损坏。接着加载操作系统进RAM。然而RAM具有临时性和易变性,ROM具有长久性和非易变性。ROM存储的内容,即使设备关闭的时候,仍然保持在原位。
Most computers have additional memory devices called mass storage (or secondary storage) systems. Three types are commonly used for personal computers: magnetic, optical, and solid state.
大多数计算机都有被称为大容量存储(或辅助存储)系统的额外存储设备。个人计算机常用的有三种类型:磁性存储、光学存储和固态存储。
Magnetic storage represents data by magnetizing microscopic particles on a disk or tape surface. The first personal computers used cassette tapes for storage, though floppy disk storage was soon available. Today, the most common example of magneticstorage technology is the magnetic disk or hard disk drive (HDD).
磁存储通过将磁盘或磁带表面的微小颗粒磁化来表示数据。最早的个人计算机使用盒式磁带进行存储,不过软盘存储很快就出现了。如今,磁存储技术最常见的例子是磁盘或硬盘驱动器(HDD)。
- microscopic 微小的
