Skip to content

Instantly share code, notes, and snippets.

@phparkle
phparkle / sto.h
Last active May 3, 2017 01:24
Converts string of decimal digits to numeric type.
#include <string>
// Converts string of decimal digits to numeric type.
template <class T>
T sto(const std::string & s)
{
T t = 0;
for (const char c : s)
t = t * 10 + c - '0';
return t;
// Write a C++ program to simulate Mark Six lottery game.
#include <iostream>
#include <string>
#include <sstream>
#include <ctime>
using namespace std;
int main()
class BottleShop {
private String answer = "a secret";
public int changeEmptyBottlesToDrinks(int emptyBottles) {
int drinks;
if (emptyBottles == 10) {
drinks = 1;
} else {
package hk.edu.cityu.ast10106.gp12.inventory.ui;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
/**
public class LabAssessmentQ1 {
public static int[] withoutTen(int[] nums){
int j = 0;
for (int i = 0; i < nums.length; i++) {
int n = nums[i];
nums[i] = 0;
public class MockTest {
public static int bigDiff(int[] nums) {
int max = nums[0];
int min = nums[0];
for (int i = 1; i < nums.length; i++) {
int n = nums[i];