Skip to content

Instantly share code, notes, and snippets.

Avatar
👣

2hanX 2hanX

👣
View GitHub Profile
View best-time-to-buy-and-sell-stock-ii.cpp
// https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/solution/mai-mai-gu-piao-de-zui-jia-shi-ji-ii-by-leetcode-s/
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
class Solution
{
public:
View remove-duplicates-from-sorted-array.cpp
// https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/solution/
#include <iostream>
#include <vector>
using namespace std;
class Solution
{
public:
int removeDuplicates(vector<int>& nums)
View change_mac_4_linux.py
import re
import subprocess
from random import choice, randint
interface = input("Enter your network interface: ").strip()
choice_num = input("Enter your new mac address[0]/random mac[1]: ").strip()
if choice_num == 0:
new_mac = input("new mac: ").strip()
else choice_num == 1:
new_mac = mac_random()
@2hanX
2hanX / defangIPaddr.cpp
Created Sep 27, 2020
给你一个有效的 IPv4 地址 address,返回这个 IP 地址的无效化版本。 所谓无效化 IP 地址,其实就是用 "[.]" 代替了每个 "."。 示例 1: 输入:address = "1.1.1.1" 输出:"1[.]1[.]1[.]1" 示例 2: 输入:address = "255.100.50.0" 输出:"255[.]100[.]50[.]0" 来源:力扣(LeetCode) 链接:https://leetcode-cn.co
View defangIPaddr.cpp
#include<iostream>
#include <string.h>
using namespace std;
string defangIPaddr(string address)
{
for (int i = 0; i < address.length(); ++i)
{
if (address[i] == '.')
{
@2hanX
2hanX / reverse_int.cpp
Created Sep 11, 2020
给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。 示例 1: 输入: 123 输出: 321 示例 2: 输入: -123 输出: -321 示例 3: 输入: 120 输出: 21 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/reverse-integer 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
View reverse_int.cpp
#include<stdio.h>
#include<limits.h>
int main(int argc, char const *argv[])
{
int x = -123;
int ans = 0;
while(x != 0)
{
int pop = x % 10;
View 6.11.8.cpp
#include<iostream>
#include<fstream>
using namespace std;
const int SIZE = 100;
int main()
{
char filename[SIZE];
ifstream inFile;
View 6.11.7.cpp
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
string a;
cout << "Enter words (q to quit): " << endl;
View 6.11.4.cpp
#include<iostream>
using namespace std;
const int strsize = 20;
const int SIZE = 5;
struct bop
{
char fullname[strsize]; // real name
char title[strsize]; //job title
View 6.11.3.cpp
#include<iostream>
using namespace std;
int main()
{
cout << "Please enter one of the following choices: " << endl;
cout << " c) carnivore \t\t\t p) pianist" << endl;
cout << " t) tree \t\t\t g) game" << endl;
char choice;
View 6.11.2.cpp
#include<iostream>
#include<array>
using namespace std;
const int SIZE = 10;
int main()
{
array<double, SIZE> donation;
double sum = 0.0;
You can’t perform that action at this time.