#include<iostream> using namespace std; int main() { double r,m,y; cout << "***** 复利计算器 ****"<< endl; cout << "银行年利率:(%)" ; cin >> r; cout << "\r\n资金数额(万元):"; cin >> m; m=m*100
#include <iostream> #include <string> #include <fstream> #define N 64 bool isPeak(int grid[][N], int r, int c); int main() { int nrows, ncols; int map[N][N]; string filename; ifstream file; cout << "请输入文
1、嵌套循环 2、跳转语句 continue不会使整个循环终止,break会跳出循环 //输出2,跳过了1 goto A; cout << 1 << endl; A: cout << 2 << endl; 3、数组
G. cocktail with snake 题意:给区间宽高:n,m,蛇形走位,问k步之后和原点的曼哈顿距离是多少 分析 int t = k / n 就是走k步后当行数 如果 t 是奇数,说明在往左走 如果 t 是偶数,说明在往右走 k % n 就是当前层往左往右走的步数 讨论一下,算出结果就行了 //------------------------
1 STL概论 STL(标准模板库): STL的分类:容器,算法和迭代器。 STL提供了6大组件:容器,算法和迭代器,仿函数、适配器(配接器)、空间配置器。 2 三大组件的初识 容器: #define _CRT_SECURE_NO_WARNINGS #include <iostream> using namespace std; #include <vector> // 容器 vector //
思路 注意重复字符串可以重叠!!!比如 \(aba\) 重复两次就可以是 \(ababa\) 。 代码 #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int N = 1000010; int test_case = 1; int n; string s; int ne[N]; int main () { while (cin >>
盘点自己较熟悉的语言作为第一个博客! C++ #include<iostream> using namespace std; int main() { cout << "Hello, world!" << endl; return 0; } Python print('Hello, world!') JavaScript console.log('Hello, world!
最近在学习C++,遇到了一个案例:猜数字游戏 案例要求:系统生成一个范围在1-100的随机整数,用户有5次猜数字的机会,当用户猜的数字大于或小于生成的值时进行提示,5次没猜对则失败,猜对则成功; 代码: #include <stdio.h> #include <iostream> #include <ctime> using namespace std; int ma
2A,C题wa2不知道为什么。B题少判一个条件:左上角 A : 题意有点不懂,到最后才知道是有多少种数,就输出这个种数-1即可 int n,m; void solve() { // cin>>n>>m; char s[4]; cin>>s[0]>>s[1]>>s[2]>>s[3]; set<int> q; fo(i,0,3) { q.insert(s[i]);
// bind example #include <iostream> // std::cout #include <functional> // std::bind // a function: (also works with function object: std::divides<double> my_divide;) double my_divide (double x, double y) {return x/y;} struct MyPa
AtCoder Beginner Contest 266 https://atcoder.jp/contests/abc266 EF 待补 A - Middle Letter 输出字符串最中间的那个字母 #include <bits/stdc++.h> using namespace std; int main () { string s; cin >> s; cout << s[(s.size()+1)/2-1]; } B - Modul
问题描述:在阅读一段代码时,发现代码的最后一部分出现 ... cout.setf(ios::fixed); cout.setf(ios::showpoint); ... 解决: cout.setf()是通过设置格式标志来控制cout输出格式 cout.setf(ios::fixed)表示用正常的记数方式来输出(与科学计数法相对应) coutsetf(ios::showpoint)表示显示
函数默认参数 在C++中,函数的形参列表中的形参是可以有默认值的。 语法: 返回值类型 函数名 (参数= 默认值){} 1 #include <iostream> 2 using namespace std; 3 void n(int a, int b, int c);//函数的声明与函数体之间只允许有一个设置默认值,即使默认值一样也不行 4 void n(int
//常规时间复杂度为 n*m // #include<bits/stdc++.h> // using namespace std; // int main() { // int n, m; // cin >> n >> m; // vector nums; // for (int i = 0; i < n; i++) { // int temp; // cin >> temp; //
C题想了一种线段树,然后统计所有左右端点的麻烦做法, A 题:思维 将长的边作为横坐标,短的边作为纵坐标,从左走到右即可。 注意当一条边横跨中间的那条线之后,另一条边只用多走一步就可以到达另一条路 //-------------------------代码---------------------------- //#define int l
题目 原题地址:Rails 题目编号:NC14326 题目类型:栈 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K 1.题目大意 入栈的元素依次从1到N,求能否实现给定的出栈序列 2.题目分析 直接做即可 本题有多个测试用例,每组测试用例给出一个N和多组数据 输入数据为0时代
1.一个指针在32位操作系统上占4个字节,一个指针在64位操作系统上占8个字节,但是,编译器为了兼容32位操作系统和64位操作系统,所以指针都是4个字节长度。 下面程序中的形参本质上是一个指针,所以无论定义了几个参数都只能传递四个字节。 #include <iostream> #include <windows.h> usin
#include <iostream> #include <Windows.h> #include <string> #include <conio.h> //getch使用 #include "hacker.h" using namespace std; #define WIDTH 40 #define HEIGHT 15 void inputPwd(char pwd[], int size) { char c;
#undef UNICODE#undef _UNICODE#include <iostream>#include <iomanip>#include <string>#include <cstdlib>#include <ctime>#include <windows.h>#include <conio.h>#include <fstream>#include <stdio.h>using name
https://www.acwing.com/problem/content/description/1580/ 思路: 这题思路并不难,但如果你傻乎乎的一种一种情况的输出,那会非常的繁琐,巧妙的利用一个函数来统一起来实现。 #include <iostream> using namespace std; typedef long long LL; LL gcd(LL a, LL b) { return b
#undef UNICODE#undef _UNICODE#include <iostream>#include <iomanip>#include <string>#include <cstdlib>#include <ctime>#include <windows.h>#include <conio.h>#include <fstream>#include <stdio.h>using name
题目描述: People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 digits for Green, and the last 2 digits for Blue. Th
#include <iostream> #include<vector> #include<algorithm> #include<cmath> #include<ctime> using std::cout; using std::vector; using std::srand; using std::time; using std::generate; using std::endl; using std::count_if; using
//2022年8月20日09:05:03 #include <iostream> using namespace std; int myFunc(int a, int b = 0)//int b = 0;这就是函数的默认参数,不一定是0 { return a + b; } void test01() { //函数的默认参数的作用 //当函数内常要用到形参的某个值,但偶尔要使用其他值
模板编程可称范型编程,是一种忽视数据类型的编程方式,这样的好处是什么?且看下面一个例子: 简单使用 求解最值问题,返回两个值中的较大值: int Max(int a, int b) { return a>b?a:b; } double Max(int a, int b) { return a>b?a:b; } string Max(string a,string b) { return a>b?a