Skip to content

Instantly share code, notes, and snippets.

Avatar

pinglunliao pinglunliao

View GitHub Profile
View b030.cpp
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
View b027.cpp
#include <iostream>
using namespace std;
int main()
{
int board[100][100] = {0};
int h, w;
cin >> h >> w;
View b026.cpp
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int seq[n];
View c032.py
import sys
msg = {0:"PERFECT", 1:"ABUNDANT", -1:"DEFICIENT"}
def checkPerfection(n):
sum = 0
for i in range(1, (n // 2) + 1, 1):
if( n % i == 0 ):
sum += i
View RobotC_NXT_Movement.c
task main()
{
// Moving Forward
motor[motorC] = 100;
motor[motorB] = 100;
wait1Msec(1000);
// Moving Backword
motor[motorC] = -100;
View socketDemo.sh
#!/bin/bash
for i in {1..5}
do
python TCP_Client.py
done
View TCP_Client.py
#!/usr/bin/python
import socket
s = socket.socket()
host = socket.gethostname() # 取得目前機器名稱
print(host)
port = 12345 # 程式的 port number
s.connect((host, port)) # 連線到 server
recvMsg = s.recv(1024) # 接收 server 傳來的訊息
View TCP_Server.py
#!/usr/bin/python
import socket
s = socket.socket()
host = socket.gethostname() # 取得目前機器名稱
print(host)
port = 12345 # 程式的 port number
s.bind((host, port))
s.listen(5) # 等待 client 連線
@pinglunliao
pinglunliao / PygameKeyboard.py
Created Jun 3, 2019
Moving a sprite with keyboard
View PygameKeyboard.py
# -*- coding: utf-8 -*-
import pygame
pygame.init()
#
# Step 1: Create the screen window
#
# Screen width, height
S_W = 500
View Two_SumOnePassHashTable.cpp
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
multimap<int, int> nTable;
multimap<int, int>::iterator it;
vector<int> result;
for(int i = 0; i < nums.size(); i++) {
int c = target - nums[i];
nTable.insert(make_pair(nums[i], i));