Skip to content

Instantly share code, notes, and snippets.

View 2hanX's full-sized avatar
:octocat:

2hanX 2hanX

:octocat:
View GitHub Profile
// 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:
// 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)
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 September 27, 2020 13:43
给你一个有效的 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
#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 September 11, 2020 13:21
给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。 示例 1: 输入: 123 输出: 321 示例 2: 输入: -123 输出: -321 示例 3: 输入: 120 输出: 21 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/reverse-integer 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
#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;
#include<iostream>
#include<fstream>
using namespace std;
const int SIZE = 100;
int main()
{
char filename[SIZE];
ifstream inFile;
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
string a;
cout << "Enter words (q to quit): " << endl;
#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
#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;
#include<iostream>
#include<array>
using namespace std;
const int SIZE = 10;
int main()
{
array<double, SIZE> donation;
double sum = 0.0;