影片連結
pass:許可
mandate:指令、下令
drowsy:想睡的
behind:支持
upending:打亂
groggy:東倒西歪的
single mother:單親媽媽
too little too late:事情已經到了這地步,現在不管做甚麼動作,都來不及補救
second grader / fourth grader:二年級生/四年級生
Get off my lawn:滾開、不要多管閒事
2020年2月29日 星期六
2020年2月27日 星期四
井字遊戲
簡單的井字遊戲,純C硬刻~
程式碼:
程式碼:
#include <stdio.h> #include <stdlib.h> #include <time.h> char map[3][3] = {'\0'}; void initializeboard() { int number = 1; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) map[i][j] = ('0'+number++); } } void printborad() { printf("-------------\n"); printf("| %c | %c | %c |\n",map[0][0],map[0][1],map[0][2]); printf("----+---+---\n"); printf("| %c | %c | %c |\n", map[1][0], map[1][1], map[1][2]); printf("----+---+----\n"); printf("| %c | %c | %c |\n", map[2][0], map[2][1], map[2][2]); printf("-------------\n"); } void playerturn() { int cmd,correct_input=0; char mark='o'; while (1) { printf("請選擇編號: "); scanf_s("%d", &cmd); if (cmd == 1 && map[0][0] == '1') map[0][0] = 'o', correct_input = 1; else if (cmd == 2 && map[0][1] == '2') map[0][1] = 'o', correct_input = 1; else if (cmd == 3 && map[0][2] == '3') map[0][2] = 'o', correct_input = 1; else if (cmd == 4 && map[1][0] == '4') map[1][0] = 'o', correct_input = 1; else if (cmd == 5 && map[1][1] == '5') map[1][1] = 'o', correct_input = 1; else if (cmd == 6 && map[1][2] == '6') map[1][2] = 'o', correct_input = 1; else if (cmd == 7 && map[2][0] == '7') map[2][0] = 'o', correct_input = 1; else if (cmd == 8 && map[2][1] == '8') map[2][1] = 'o', correct_input = 1; else if (cmd == 9 && map[2][2] == '9') map[2][2] = 'o', correct_input = 1; else printf("錯誤輸入,請再輸入一次!\n"); if (correct_input) break; } } void computerturn() { int x = rand() % 3, y = rand() % 3,i=0; while (map[x][y] == 'o' || map[x][y] == 'x') { x = rand() % 3, y = rand() % 3; i++; if (i >= 9) return; } map[x][y] = 'x'; } int winorlose() { // o win if (map[0][0] == 'o'&&map[0][1] == 'o'&&map[0][2] == 'o') return 1; //橫向 if (map[1][0] == 'o'&&map[1][1] == 'o'&&map[1][2] == 'o') return 1; if (map[2][0] == 'o'&&map[2][1] == 'o'&&map[2][2] == 'o') return 1; if (map[0][0] == 'o'&&map[1][0] == 'o'&&map[2][0] == 'o') return 1; //縱向 if (map[0][1] == 'o'&&map[1][1] == 'o'&&map[2][1] == 'o') return 1; if (map[0][2] == 'o'&&map[1][2] == 'o'&&map[2][2] == 'o') return 1; if (map[0][0] == 'o'&&map[1][1] == 'o'&&map[2][2] == 'o') return 1; //斜向 if (map[0][2] == 'o'&&map[1][1] == 'o'&&map[2][0] == 'o') return 1; // x win if (map[0][0] == 'x'&&map[0][1] == 'x'&&map[0][2] == 'x') return 2; if (map[1][0] == 'x'&&map[1][1] == 'x'&&map[1][2] == 'x') return 2; if (map[2][0] == 'x'&&map[2][1] == 'x'&&map[2][2] == 'x') return 2; if (map[0][0] == 'x'&&map[1][0] == 'x'&&map[2][0] == 'x') return 2; //縱向 if (map[0][1] == 'x'&&map[1][1] == 'x'&&map[2][1] == 'x') return 2; if (map[0][2] == 'x'&&map[1][2] == 'x'&&map[2][2] == 'x') return 2; if (map[0][0] == 'x'&&map[1][1] == 'x'&&map[2][2] == 'x') return 2; //斜向 if (map[0][2] == 'x'&&map[1][1] == 'x'&&map[2][0] == 'x') return 2; int record = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (map[i][j] == 'o' || map[i][j] == 'x') record++; } } if (record == 9) return 3; return 0; } int main() { srand(time(NULL)); printf("\n\n\n"); printf("\t\t\t~~歡迎來玩 井字遊戲~~\n\n"); printf("\t\t\t <規則>\n"); printf("\t\t\t1.玩家為先手,與電腦對決\n"); printf("\t\t\t2.先連成一線者獲勝\n\n\n"); system("pause"); system("cls"); initializeboard(); int result = 0; while (1) { system("cls"); printborad(); playerturn(); if ((result = winorlose()) != 0) break; computerturn(); if ((result = winorlose()) != 0) break; } system("cls"); printborad(); if (result == 1) printf("你贏了~\n"); else if (result == 2) printf("你輸了~\n"); else if (result == 3) printf("平手~\n"); system("pause"); return 0; }
2020年2月25日 星期二
What's it like to work at Google?
影片連結
無法觸及的夢幻之境啊~QQ
vibe:氛圍
gratifying:令人滿足的
forefront:最前線
leapfrog:越級提升
preconceived:先入為主的
push the boundaries:挑戰極限
reassuring:使安心
value:重視
show up:出席、到來
無法觸及的夢幻之境啊~QQ
vibe:氛圍
gratifying:令人滿足的
forefront:最前線
leapfrog:越級提升
preconceived:先入為主的
push the boundaries:挑戰極限
reassuring:使安心
value:重視
show up:出席、到來
2020年2月24日 星期一
00147 - Dollars
解題思路:
零錢問題。我直接把0~300.00想成0~30000元去算,唯一要稍微注意的是小數在乘的時候會有誤差。
程式碼:
零錢問題。我直接把0~300.00想成0~30000元去算,唯一要稍微注意的是小數在乘的時候會有誤差。
程式碼:
#include <stdio.h> #define N 30000 long long int s[N+1]={0}; int C[11]={5,10,20,50,100,200,500,1000,2000,5000,10000}; int main() { double n; s[0]=1; for(int i=0;i<11;i++) { for(int j=C[i];j<=N;j++) s[j]+=s[j-C[i]]; } while(scanf("%lf",&n)&&n) { n+=1e-6; printf("%6.2lf",n); printf("%17lld\n",s[(int)(n*100)]); } return 0; }
2020年2月23日 星期日
Australia's wildfires are still raging. Here's what you need to know.
影片連結
at any given time:隨時
lightning:閃電
inadvertently:不小心的
bushfire:山火、叢林大火
nature preserve:自然保留區
taking a (big) hit:受到打擊
fire crews :消防隊員
at any given time:隨時
lightning:閃電
inadvertently:不小心的
bushfire:山火、叢林大火
nature preserve:自然保留區
taking a (big) hit:受到打擊
fire crews :消防隊員
2020年2月21日 星期五
Wuhan Coronavirus: What You Should Know
影片連結
respiratory tract:呼吸道
pneumonia:肺炎
flu shot:流感疫苗
Influenza:流感
ventilator:呼吸器
etiquette:禮儀
hand gel:乾洗手
respiratory tract:呼吸道
pneumonia:肺炎
flu shot:流感疫苗
Influenza:流感
ventilator:呼吸器
etiquette:禮儀
hand gel:乾洗手
d140: On Sale
解題思路:
大致上就是照著題目直觀去解,只是要注意1.誤差問題2.無條件捨去至第二位
1.誤差:由於小數在儲存時有誤差,運算時為避免錯誤要加上
2.無條件捨去:使用floor()函數(如求無條件進位則用ceil())
程式碼:
#include <stdio.h> #include <math.h> int main() { double m; while(scanf("%lf",&m)!=EOF) { int check=0; if(m<100) check=1; if(m<=100) m*=0.9; else if(m<=500) m*=0.8; else m*=0.6; if(check) m+=8; m+=1e-6; printf("$%.2lf\n",floor(m*100)/100); } return 0; }
2020年2月20日 星期四
c672: RGB ⇆ HEX
解題思路:
先了解RGB與HEX兩種分別是十進位與十六進位轉換,接著想辦法把三色分別取出即可。
程式碼:
先了解RGB與HEX兩種分別是十進位與十六進位轉換,接著想辦法把三色分別取出即可。
程式碼:
#include <stdio.h> int main() { char s[12]; while(gets(s)!=0) { if(s[0]=='#') { int r,g,b; sscanf(s,"#%02x%02x%02x",&r,&g,&b); printf("%d %d %d\n",r,g,b); } else { int r,g,b; sscanf(s,"%d %d %d",&r,&g,&b); printf("#%02X%02X%02X\n",r,g,b); } } return 0; }
2020年2月19日 星期三
The Accidental Invention of the Best Snack Food Ever
影片連結
snarky:諷刺的
idiosyncratic:特別的
made their way to :(艱辛費時的)前往
mainstay:支柱
signature dish:招牌菜
hoity-toity:傲慢的;高不可攀的
aristocrat:貴族
scoff:嘲笑
soggy:浸水的
insanity:瘋狂;荒唐的行為
lost it:抓狂了
fire back:回擊
faux pas:失禮
diabolical:惡魔的
backfire:產生反效果
dig in:吃
thereafter:從那之後
took the world by storm:席捲世界
snarky:諷刺的
idiosyncratic:特別的
made their way to :(艱辛費時的)前往
mainstay:支柱
signature dish:招牌菜
hoity-toity:傲慢的;高不可攀的
aristocrat:貴族
scoff:嘲笑
soggy:浸水的
insanity:瘋狂;荒唐的行為
lost it:抓狂了
fire back:回擊
faux pas:失禮
diabolical:惡魔的
backfire:產生反效果
dig in:吃
thereafter:從那之後
took the world by storm:席捲世界
2020年2月18日 星期二
21點
很簡單的21點小遊戲。
無法不要牌繼續。
無法不要牌繼續。
#include <stdio.h> #include <stdlib.h> #include <time.h> int card[13] = { 0 }; int player_point = 0, computer_pount = 0, temp_record; int get_card() { int point = rand() % 13 + 1;//1~13 while (card[point] >= 4) { point = rand() % 13 + 1; } card[point]++; return point; } void player_get_card() { temp_record = get_card(); player_point += temp_record; printf("你拿到一張牌: [%d]\n",temp_record); printf("你的總點數為: %d\n", player_point); } void computer_get_card() { printf("電腦拿了一張牌\n"); computer_pount += get_card(); } void lose_or_win() { if (player_point > 21 && computer_pount > 21) printf("兩方都輸啦!!"); else if (player_point > 21) printf("你輸啦!!"); else if (computer_pount > 21) printf("你贏啦!!"); else if (player_point > computer_pount) printf("你贏啦!!"); else if (player_point < computer_pount) printf("你輸啦!!"); else if (player_point == computer_pount) printf("平手啦!!"); } int main() { srand(time(NULL)); char cmd; printf("\n\n"); printf("~~歡迎來玩 21點 小遊戲~~\n\n"); system("pause"); system("cls"); player_get_card(); computer_get_card(); while (1) { printf("-----------------------"); printf("\n\n"); printf("請問要繼續嗎? (y/n)\n"); printf("y: 繼續 n:結束此局\n"); scanf_s("%c", &cmd); getchar(); if (cmd == 'n' || cmd == 'N') break; printf("-----------------------"); printf("\n"); player_get_card(); computer_get_card(); if (player_point > 21 || computer_pount > 21) break; } printf("-----------------------\n\n"); printf("你的點數: %d\n", player_point); printf("電腦的點數: %d\n", computer_pount); printf("\n"); lose_or_win(); system("pause"); return 0; }
早餐生成器
有選擇障礙症,因此產出的簡單小程式
#include <stdio.h> #include <time.h> #include <stdlib.h> void breakfast() { int food = rand() % 8; printf("\n"); char menu[10][10] = { "包子","三明治","香腸炒蛋","香腸","炒蛋","蛋餅","蔥油餅","絕食" }; printf("就決定是你了 ── %s !!\n\n", menu[food]); } void lunch() { int food = rand() % 7; printf("\n"); char menu[20][20] = { "炒飯","池上便當","燒賣","水餃","鍋貼","便當","媽媽愛心午餐" }; printf("那就吃 %s 好了~\n\n", menu[food]); } void dinner() { int food = rand() % 8; printf("\n"); char menu[20][20] = { "火鍋","壽司","麥當勞","摩斯","吉野家","炒飯","漢堡王","披薩" }; printf("吃 %s 感覺很不錯!\n\n", menu[food]); } int main() { int command; system("color f0"); srand(time(NULL)); printf("================\n"); printf("歡迎來到 菜單生成器\n"); printf("================\n"); printf("\n\n"); while (1) { char c; printf("1) 早餐\n"); printf("2) 午餐\n"); printf("3) 晚餐\n"); printf("請輸入選項: "); scanf_s("%d", &command); getchar(); if (command == 1) breakfast(); else if (command == 2) lunch(); else if (command == 3) dinner(); else printf("請好好輸入好嗎=口=\n"); printf("\n"); while (1) { printf("還要繼續嗎? y=繼續 n=結束\n"); scanf_s("%c", &c); getchar(); if (c == 'n' || c == 'N' || c == 'y' || c == 'Y') break; else printf("請好好輸入好嗎=口=\n\n"); printf("\n"); } if (c == 'n' || c == 'N') break; printf("\n"); } printf("~~~~謝謝你的光臨~~~~\n"); system("pause"); return 0; }
2020年2月16日 星期日
Chernobyl (2019) | Official Trailer | HBO
影片連結
不看字幕就看不懂....程度太差QQ
justice was done:伸張正義
just:公正的、正義的
sane:理智的
on fire:起火
uranium:鈾
firing:發射
contain:遏止
misinformation:誤傳
madness:瘋狂的行為
不看字幕就看不懂....程度太差QQ
justice was done:伸張正義
just:公正的、正義的
sane:理智的
on fire:起火
uranium:鈾
firing:發射
contain:遏止
misinformation:誤傳
madness:瘋狂的行為
2020年2月14日 星期五
10098 - Generating Fast, Sorted Permutation
這題zerojudge上測資有問題,丟uva就過了,傻眼orz
其實對這種字串排序還是不怎麼熟,是把工具套一套解出來的。
步驟:
1.對字串進行排序
2.next_permutation
程式碼:
參考:https://stackoverflow.com/questions/17006808/find-all-permutations-of-a-string-in-c
next_permutation是字典序較大的放右邊,而與之相反的則是prev_permutation。
相關題目:d703: SOS ~~~
其實對這種字串排序還是不怎麼熟,是把工具套一套解出來的。
步驟:
1.對字串進行排序
2.next_permutation
程式碼:
#include <iostream> #include <algorithm> using namespace std; int main() { int n; cin>>n; getchar(); while(n--) { string s; getline(cin,s); int len=s.size(); sort(s.begin(),s.end()); do{ cout<<s<<endl; }while(next_permutation(s.begin(),s.end())); cout<<endl; } return 0; }
參考:https://stackoverflow.com/questions/17006808/find-all-permutations-of-a-string-in-c
next_permutation是字典序較大的放右邊,而與之相反的則是prev_permutation。
相關題目:d703: SOS ~~~
2020年2月13日 星期四
Opinion | Trump's racist tweets will not age well
影片連結
Democrat:民主黨員
congresswoman:女眾議員
inept:無能的
viciously:邪惡的
infest:(動物、害蟲)大批出沒
tweet:在推特上發文
common cause:共同追求的目標
duly:合適的
Israel:以色列
Democrat:民主黨員
congresswoman:女眾議員
inept:無能的
viciously:邪惡的
infest:(動物、害蟲)大批出沒
tweet:在推特上發文
common cause:共同追求的目標
duly:合適的
Israel:以色列
2020年2月11日 星期二
2020年2月8日 星期六
Paolo Cardini: Forget multitasking, try monotasking
影片連結
supertasker:能同時完成多件事的人
front cover:手機殼(但網路查的結果都是:封面,可能這裡只是單純想表達「把前面蓋住的東西」)
downgrade:降級
Venice:威尼斯
How beautiful it is to lose ourselves in these little streets:這些小街道是如此美麗的令人忘我
supertasker:能同時完成多件事的人
front cover:手機殼(但網路查的結果都是:封面,可能這裡只是單純想表達「把前面蓋住的東西」)
downgrade:降級
Venice:威尼斯
How beautiful it is to lose ourselves in these little streets:這些小街道是如此美麗的令人忘我
2020年2月6日 星期四
Arthur Benjamin: Teach statistics before calculus!
影片連結
Don't get me wrong:別誤會我的意思
day-to-day:日常的
mess:混亂局面
analog:類比
discrete:離散的
standard deviation:標準差
Don't get me wrong:別誤會我的意思
day-to-day:日常的
mess:混亂局面
analog:類比
discrete:離散的
standard deviation:標準差
2020年2月4日 星期二
How to tie your shoes | Terry Moore
影片連結
worldly:善於處世的
savvy:有領悟力
ludicrous:荒唐的
laces:鞋帶
nail:成功學會
strand:繩
orient:使朝向
long axis:長軸
bow:結
start over:重來
cord:繩、線
transverse:縱向的
in keeping with:呼應、與...一致
Live long and prosper:生生不息,繁榮昌盛(源自星際大戰)
worldly:善於處世的
savvy:有領悟力
ludicrous:荒唐的
laces:鞋帶
nail:成功學會
strand:繩
orient:使朝向
long axis:長軸
bow:結
start over:重來
cord:繩、線
transverse:縱向的
in keeping with:呼應、與...一致
Live long and prosper:生生不息,繁榮昌盛(源自星際大戰)
2020年2月2日 星期日
質數
質數篩法
其他
#define N 100 int isprime[N]; int prime[N],pnum; void sieve(int n) { pnum=0; for(int i=0;i<n;i++) isprime[i]=1; isprime[0]=isprime[1]=0; int sqn=sqrt(n); for(int i=2;i<=sqn;i++) { if(isprime[i]) { prime[pnum++]=i; for(int j=i*i;j<n;j+=i) isprime[j]=0; } } for(int i=sqn+1;i<=n;i++) { if(isprime[i]) prime[pnum++]=i; } }
其他
int isprime[N]={1,1}; int sqn=sqrt(N); for(int i=2;i<=sqn;i++) { if(!isprime[i]) { for(int j=i*i;j<N;j+=i) isprime[j]=1; } }
int Prime[100], Pt; void Sieve() { Pt = 0; int i, j, mark[100] = {0}; Prime[Pt++] = 2; for(i = 3; i < 100; i += 2) { if(mark[i] == 0) { Prime[Pt++] = i; for(j = 3; i*j < 100; j += 2) mark[i*j] = 1; } } }質因數
#include <stdio.h> #include <math.h> #define M 1000 #define N 10000 int fact[M],count[M],fnum; int prime[N],isprime[N],pnum; void sieve() { int sqn=sqrt(N); isprime[0]=isprime[1]=1; for(int i=2;i<N;i++) { if(!isprime[i]) { for(int j=i+i;j<=N;j+=i) isprime[j]=1; } } pnum=0; for(int i=0;i<N;i++) { if(!isprime[i]) prime[pnum++]=i; } } void factorization(int n) { fnum=0; for(int i=0;i<pnum&&n>1;i++) { if(n%prime[i]==0) { fact[fnum]=i; count[fnum]=0; fnum++; while(n%prime[i]==0) { count[fnum-1]++; n/=prime[i]; } } } } int main() { sieve(); factorization(120); printf("%d = \n",120); for(int i=0;i<fnum;i++) printf("%d^%d\n",prime[fact[i]],count[i]); return 0; }
2020年2月1日 星期六
8 secrets of success
影片連結
make something of one's life:有所成就
pass it on to :傳達給
what makes (one) tick:促使某人做某事的原因
workafrolic:作者自創字。對比工作狂(workaholic),字根frolic有:「快樂做某事」的意思,因此字幕翻譯成工作玩家。
put your nose down in something:專注某事,實際去做(不確定意思)
make something of one's life:有所成就
pass it on to :傳達給
what makes (one) tick:促使某人做某事的原因
workafrolic:作者自創字。對比工作狂(workaholic),字根frolic有:「快樂做某事」的意思,因此字幕翻譯成工作玩家。
put your nose down in something:專注某事,實際去做(不確定意思)
訂閱:
文章 (Atom)