引用头文件的语法 使用预处理指令 #include 可以引用用户和系统头文件。它的形式有以下两种:
C++多态意味着调用成员函数时,会根据调用函数的对象的类型来执行不同的函数;
algorithm.h
引入头文件queue
C++ 类定义
#include <iostream> #include <algorithm> #include<math.h> #include<string> #include<vector> #include<ctype.h> #include<set> using namespace std; int main() { #ifdef LOCAL freopen("D:\\datain.txt", "r", stdin); #endif int n; cin >> n; int d[100005]; fill(d, d + 100005, 0); int a; int b; for (int i = 0; i < n; i++) { scanf("%d %d", &a, &b); d[a] += b; } int maxd = 0.0; int maxi = 0; for (int i = 0; i < 100005; i++) { if (d[i] > maxd) { maxd = d[i]; maxi = i; } } printf("%d %d", maxi, maxd); }
//cpp: #include <iostream> #include <algorithm> #include<math.h> #include<string> #include<vector> #include<ctype.h> #include<set> using namespace std; int main() { #ifdef LOCAL freopen("D:\\datain.txt", "r", stdin); #endif int n; string a; cin >> n; char m[12] = { '1','0','X','9','8','7','6','5','4','3','2' }; int b[17] = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 }; bool flag = true; for (int i = 0; i < n; i++) { cin >> a; int sum = 0; for (int j = 0; j < 17; j++) { sum += (a[j] - '0')*b[j]; //cout << "+" << a[j] - '0'; } //cout <<"sum"<< sum << endl; sum = sum % 11; //cout << sum << endl; //cout << m[sum] << endl; if (m[sum] != a[17]) { cout << a << endl; flag = false; } } if (flag) cout << "All passed"; }
//cpp: #include <iostream> #include <algorithm> #include<math.h> #include<string> #include<vector> #include<ctype.h> #include<set> using namespace std; int main() { #ifdef LOCAL freopen("D:\\datain.txt", "r", stdin); #endif int n, p; cin >> n >> p; long long d[100005]; for (int i = 0; i < n; i++) { scanf("%lld", &d[i]); } sort(begin(d), begin(d) + n); int maxc = 0; for (int i = 0; i < n; i++) { for (int j = i + maxc; j < n; j++) { if (d[j] <= d[i] * p) { int t = j - i + 1; if (t > maxc) maxc = t; } else break; } } cout << maxc; return 0; }
//cpp: #include <iostream> #include <algorithm> #include<math.h> #include<string> #include<vector> #include<ctype.h> #include<set> using namespace std; int main() { #ifdef LOCAL freopen("D:\\datain.txt", "r", stdin); #endif string a, b; cin >> a >> b; int j = 0; set<char> s; for (int i = 0; i < b.length(); i++) { while (a[j] != b[i]) { if(s.find(toupper(a[j]))==s.end()) printf("%c", toupper(a[j])); s.insert(toupper(a[j])); //cout << a[j]; j++; } j++; //cout << "++++" << b[i] << endl; } while (j < a.length()) { if (s.find(toupper(a[j])) == s.end()) printf("%c", toupper(a[j])); s.insert(toupper(a[j])); //cout << a[j]; j++; } return 0; }
//cpp: #include <iostream> #include <algorithm> #include<math.h> #include<string> using namespace std; int main() { #ifdef LOCAL freopen("D:\\datain.txt", "r", stdin); #endif string max1, min1; int count = 0; int n; cin >> n; string t1,t2; string min2 = "1814/09/06"; string max2 = "2014/09/06"; max1 = min2; min1 = max2; string min3, max3; for (int i = 0; i < n; i++) { cin >> t1 >> t2; if (t2 >= min2 && t2 <= max2) { count++; if (t2 >= max1) { max1 = t2; max3 = t1; } if (t2 <= min1) { min1 = t2; min3 = t1; } } } cout << count; if(count>0) cout<<" " << min3 << " " << max3; return 0; }
大学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.