Yan Feng frankie-yanfeng
-
AIQ
- Singapore
- Sign in to view email
- https://frankie-yanfeng.github.io/
View forRangeNoMemoryCost.go
package main | |
import "fmt" | |
func main() { | |
var times [5][0]int | |
for range times { | |
fmt.Println("hello") | |
} |
View gcp_bucket_creation.py
# change these to try this notebook out | |
BUCKET = 'cloud-training-demos-ml' | |
PROJECT = 'cloud-training-demos' | |
REGION = 'us-central1' | |
import os | |
os.environ['BUCKET'] = BUCKET | |
os.environ['PROJECT'] = PROJECT | |
os.environ['REGION'] = REGION |
View sql_query.py
# Create function that finds the number of records and the average weight for each value of the chosen column | |
def get_distinct_values(column_name): | |
sql = """ | |
SELECT | |
{0}, | |
COUNT(1) AS num_babies, | |
AVG(weight_pounds) AS avg_wt | |
FROM | |
publicdata.samples.natality | |
WHERE |
View operatorOverridingMemberFunction.cpp
#include <iostream> | |
using namespace std; | |
class Complex { | |
public: | |
Complex( double r= 0.0, double m = 0.0 ):real(r), imaginary(m) { } // constructor | |
Complex operator+ ( const Complex & ); // addition | |
Complex operator- ( const Complex & ); // subtraction | |
void getValue(){ cout << "real:" << this->real << " imaginary:" << this->imaginary << endl;} |
View operatorOverriding.cpp
#include <iostream> | |
using namespace std; | |
class Complex { | |
public: | |
Complex( double r = 0.0, double i= 0.0 ){ | |
real = r; | |
imaginary = i; | |
} |
View enclosing.cpp
class CTyre { //轮胎类 | |
private: | |
int radius; //半径 | |
int width; //宽度 | |
public: | |
CTyre(int r, int w):radius(r), width(w) { } | |
}; | |
class CEngine { //引擎类 | |
}; |
View typeChangeConstructor.cpp
#include <iostream> | |
using namespace std; | |
class Complex { | |
public: | |
double real, imag; | |
Complex( int i ) { //类型转换构造函数 | |
cout << "IntConstructor called" << endl; | |
real = i; imag = 0; |
View constructorArray.cpp
#include <iostream> | |
using namespace std; | |
class CSample { | |
int x; | |
public: | |
CSample() { | |
cout << "Constructor 1 Called" << endl; | |
} |
View privateConstructor.cpp
class WonderfulClass | |
{ | |
public: | |
static WonderfulClass* makeAnObject() | |
{ | |
// 创建一个WonderfulClass对象并返回其指针 | |
return (new WonderfulClass); | |
} | |
private: | |
WonderfulClass() { } |
View comma_sep.cpp
#include <iostream> | |
#include <string> | |
#include <math.h> | |
#include <vector> | |
#include <sstream> | |
using namespace std; | |
int main() { | |
char Name[30]; |