```c++ #include #include #include #include #include<map> #include #include #include #include using namespace std;
#include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> #include<map> #include<string> #include<fstream> #include<vector> #include<functional> using namespace std; bool isprime(int n) { for (int i = 2; i*i <= n; i++) { if (n % i == 0) return false; } return true; } int main() { #ifdef LOCAL freopen("d:\\datain.txt", "r", stdin); freopen("d:\\dataout.txt", "w", stdout); #endif LOCAL int n; cin >> n; int count = 0; for (int i = 5; i <= n; i++) { if (isprime(i - 2) && isprime(i)) count++; } cout << count; return 0; }
#include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> #include<map> #include<string> #include<fstream> #include<vector> #include<functional> using namespace std; int main() { #ifdef LOCAL freopen("d:\\datain.txt", "r", stdin); freopen("d:\\dataout.txt", "w", stdout); #endif LOCAL char p[4]; scanf("%s", p); int n = strlen(p); if (n == 3) { int a = p[0] - '0'; int b = p[1] - '0'; int c = p[2] - '0'; for(int j=0;j<a;j++) cout << "B"; for (int j = 0; j < b; j++) cout << "S"; for (int j = 1; j <= c; j++) cout << j; } if (n == 2) { int a = p[0] - '0'; int b = p[1] - '0'; for (int j = 0; j<a; j++) cout << "S"; for (int j = 1; j <= b; j++) cout << j; } if (n == 1) { int a = p[0] - '0'; for (int j = 1; j <= a; j++) cout << j; } return 0; }
```c++ #include #include #include #include #include<map> #include #include #include #include using namespace std; int main() { #ifdef LOCAL freopen("d:\\datain.txt", "r", stdin); freopen("d:\\dataout.txt", "w", stdout); #endif LOCAL int n; cin >> n; vector v(n); int b; int arr[10000]; fill(arr, arr + 10000, 0); for (int i = 0; i < n; i++) { cin >> b; v[i] = b; while (b != 1) { if (b % 2 != 0) b = b * 3 + 1;
```c++
```c++
C string.h char st[100]; 1. 字符串长度 strlen(st); 2. 字符串比较 strcmp(st1,st2); strncmp(st1,st2,n); 把st1,st2的前n个进行比较。 3. 附加 strcat(st1,st2); strncat(st1,st2,n); n表示连接上st2的前n个给st1,在最后不要加'\0'。 4. 替换 strcpy(st1,st2); strncpy(st1,st2,n); n表示复制st2的前n个给st1,在最后要加'\0'。 5. 查找 where = strchr(st,ch) ch为要找的字符。 where = strspn(st1,st2); 查找字符串。 where = strstr(st1,st2); C++ string string str; 1. 字符串长度 len = str.length(); len = str.size(); 2. 字符串比较 可以直接比较 也可以: str1.compare(str2); str1.compare(pos1,len1,str2,pos2,len2); 值为负,0 ,正。 nops 长度到完。 3. 附加 str1 += str2; 或 str1.append(str2); str1.append(str2.pos2,len2); 4. 字符串提取 str2 = str1.substr(); str2 = str1.substr(pos1); str2 = str1.substr(pos1,len1); string a=s.substr(0,4); //获得字符串s中 从第0位开始的长度为4的字符串 5. 字符串搜索 where = str1.find(str2); where = str1.find(str2,pos1); pos1是从str1的第几位开始。 where = str1.rfind(str2); 从后往前搜。 6. 插入字符串 不是赋值语句。 str1.insert(pos1,str2); str1.insert(pos1,str2,pos2,len2); str1.insert(pos1,numchar,char); numchar是插入次数,char是要插入的字符。 7. 替换字符串 str1.replace(pos1,str2); str1.replace(pos1,str2,pos2,len2); 8. 删除字符串 str.erase(pos,len) str.clear(); 9. 交换字符串 swap(str1,str2); 10. C --> C++ char *cstr = "Hello"; string str1; cstr = cstr; string str2(cstr);
sort需要引入algorithm
win10 快捷键
大学Java课程设计: 基于websocket的web聊天室 Spring + Spring MVC + Mybatis + mysql
大学数据库课程设计: 基于Web的宾馆管理系统 jsp+servlet+mysql 前端semantic MVC
godal provides the ability to generate specific golang code. The godal is to enable developers to write fast code in an expressive way.