回傳三角形斜邊

double hypot(double x, double y);
float hypot(float x, float y);
long double hypot(long double x, long double y);

加速cout/cin,用了之後無法跟 scanf/printf 混用,注意

而且不能跟while(cin >> input)同時使用,好像會有bug

ios::sync_with_stdio(0);
cin.tie(0);

<aside> 💡 EOF > Ctrl+Z 🔸(small orange diamond)

</aside>

設定output txt file

#include <fstream>

fstream file;
file.open("output.txt");
fclose(fopen("output.txt", "w")); //將資料清空

file << answer << endl; //用法跟cout一樣,記得提交時改回cout

排列next_permutation

string s = "Abc";
next_permutation(s.begin(), s.end());
next_permutation(s.begin(), s.end(), compare);
//bool compare(){...}

bitset

使用目的類似boolean array,但空間和時間快上許多

#include <bitset>
using namespace std;

int main(){
	bitset<10> b;
	
	string s = "10001001";
	bitset<10> b(s);
	
	cout << b[0]; //1

	b.size();
	b.any(); //判斷是否有1
	b.none(); //判斷是否沒1
	b.count(); //1的個數  size - count = 0的個數 

	b.set(); //都設為1
	b.reset(); //都設為0
}

sort map

emplace vs push & push_back

字串處理

isalpha(char c); //判斷是否是字母 是回傳true 否回傳fasle
islower(char c);
isupper(char c);
isdigit(char c);