├── 1410931042 ├── w6 ├── ran ├── readme └── w7 ├── 1411031012 ├── readme ├── W6 └── W5 ├── 1411031035 ├── readme ├── week 7 ├── week 16 ├── week 4 ├── week 6 └── week 10 Q1 ├── 1411053034 └── readme ├── 1411131001 ├── readme ├── week6 第一題 ├── week16 Q2 ├── week16 Q3 ├── week6 ├── week16 Q1 └── week 11 1-2 ├── 1411131003 ├── readme ├── week7 (1) ├── week5 (1) ├── week3 (2) ├── week10 (1)費伯納 ├── week16(2)大小寫互換 ├── week6 (1) └── week11 (2)搜尋成績 ├── 1411131005 ├── 1 ├── 2 └── readme ├── 1411131007 ├── readme ├── week2-2 ├── week16-2 ├── week6 ├── week7 ├── week16-3 ├── week10-1 ├── week2-1 ├── week4-2 ├── week11 (原始程式) ├── week4-1 ├── week16-1 ├── week5 ├── week10-2 └── week3 ├── 1411131009 ├── 1012 ├── 1019 ├── 1116 ├── readme ├── 1228-2 ├── 1228-1 └── 1116-2 ├── 1411131011 ├── readme ├── week7 ├── week5 5.5 ├── week 6 ├── week 10-1 ├── week1 2.16 ├── week 4-2 ├── week5 └── week2 ├── 1411131013 └── week6 ├── 1411131015 ├── readme └── week6 ├── 1411131017 ├── readme ├── week7 遞迴 ├── week6 P.250延伸練習 └── week 5 ├── 1411131019 ├── 1005 ├── readme ├── 1228-2 ├── practice1 ├── 1019-rand ├── 1228-1 └── 1228-3 ├── 1411131021 ├── 11 │ └── 23-W11 ├── readme ├── W6-3 ├── W5-1 ├── W5-3 ├── 1228-W16-2 ├── W6-1 ├── W7-2 ├── 1116-W10-1 ├── W4-1 ├── W3-2 └── W3-3 ├── 1411131023 ├── week 12 P2 ├── week16 P2 ├── week 16 P3 ├── week10 P1 ├── week16 P1 ├── week6 └── week 10 P2 ├── 1411131025 └── readme ├── 1411131027 ├── readme └── week5 ├── 1411131029 ├── readme ├── week1 (2.17) ├── week1 (2.16) ├── week7 ├── week6-1 ├── week4-2 └── week11-Q1 ├── 1411131031 └── readme ├── 1411131033 ├── 3 ├── readme ├── week7 ├── week4 ├── week10-1 ├── week10-2 ├── week6 └── week16 ├── 1411131035 ├── readme ├── week2物理速度計算 ├── week7階層 ├── week4利率計算 ├── week2運算符號測試 ├── week10_修改306、307頁的程式fig06_06.c ├── week7費伯納西 ├── week4及格率計算2 ├── week5階層函數+副程式2 └── week6隨機數產生_5.10章 ├── 1411131037 ├── readme ├── week6 └── week4 ├── 1411131039 ├── 1116 ├── 20220921 ├── 20220928 ├── readme ├── 1026Q1 ├── 1012Q1 ├── 1012Q2 ├── 1228Q2 ├── 0921Q1 ├── 1019Q1 ├── 0921Q2 ├── 1228Q3 ├── 1116Q1 ├── 1228Q1 ├── 1005Q2 ├── 1005Q1 ├── 1116Q2 ├── 1123Q2 └── 0928Q1 ├── 1411131041 ├── readme ├── week2 ├── week7-test ├── week4 ├── week6-test ├── week4-test ├── week5 └── week3 ├── 1411131043 └── readme ├── 1411131045 ├── readme ├── class-week7.cpp ├── class-week6.cpp └── 陣列3.cpp ├── 1411131047 ├── readme ├── 0921216.cpp ├── 0921217.cpp ├── 22-12-28-2.cpp ├── 22-12-28-3.cpp ├── 22-12-28-1.cpp ├── 22-11-16-1.cpp ├── 2022-10-5-2.cpp ├── 22-11-16-p2-1.cpp ├── 22-10-19.cpp ├── 2022-10-5-1.cpp ├── 0928-2.19.cpp ├── 22-10-12.cpp ├── 22-10-26.cpp ├── 22-11-16-p2-2.cpp └── 22-12-7-1.cpp ├── 1411131049 ├── readme ├── w16 q2 ├── w16 q3 ├── w7 ├── w16 q1 ├── w10 01 ├── W4 ├── w6 └── w11 線性搜尋 ├── 1411131051 └── 利率 ├── 1411131053 ├── 1 │ └── 1 │ │ ├── 1 │ │ ├── Debug │ │ │ ├── 1.log │ │ │ ├── 1.ilk │ │ │ ├── 1.obj │ │ │ ├── vc142.idb │ │ │ ├── vc142.pdb │ │ │ ├── 1.tlog │ │ │ │ ├── link.read.1.tlog │ │ │ │ ├── link.write.1.tlog │ │ │ │ └── link.command.1.tlog │ │ │ └── 1.exe.recipe │ │ ├── 1.vcxproj.user │ │ └── 1.vcxproj.filters │ │ └── Debug │ │ ├── 1.exe │ │ └── 1.pdb ├── 2 │ └── 2 │ │ └── 2 │ │ ├── 2.vcxproj.user │ │ └── 2.vcxproj.filters ├── 3 │ └── 3 │ │ ├── 3 │ │ ├── Debug │ │ │ ├── 3.log │ │ │ ├── 3.ilk │ │ │ ├── 3.obj │ │ │ ├── vc142.idb │ │ │ ├── vc142.pdb │ │ │ ├── 3.tlog │ │ │ │ ├── CL.read.1.tlog │ │ │ │ ├── CL.command.1.tlog │ │ │ │ ├── CL.write.1.tlog │ │ │ │ ├── link.read.1.tlog │ │ │ │ ├── link.write.1.tlog │ │ │ │ ├── link.command.1.tlog │ │ │ │ └── 3.lastbuildstate │ │ │ └── 3.exe.recipe │ │ └── 3.vcxproj.user │ │ └── Debug │ │ ├── 3.exe │ │ └── 3.pdb ├── 4 │ └── 4 │ │ ├── 4 │ │ ├── Debug │ │ │ ├── 4.log │ │ │ ├── 4.ilk │ │ │ ├── 4.obj │ │ │ ├── 4.obj.enc │ │ │ ├── vc142.idb │ │ │ ├── vc142.pdb │ │ │ ├── 4.tlog │ │ │ │ ├── CL.read.1.tlog │ │ │ │ ├── CL.command.1.tlog │ │ │ │ ├── CL.write.1.tlog │ │ │ │ ├── link.read.1.tlog │ │ │ │ ├── link.write.1.tlog │ │ │ │ ├── link.command.1.tlog │ │ │ │ └── 4.lastbuildstate │ │ │ └── 4.exe.recipe │ │ └── 4.vcxproj.user │ │ └── Debug │ │ ├── 4.exe │ │ └── 4.pdb ├── 5 │ └── 5 │ │ ├── 5 │ │ ├── Debug │ │ │ ├── 5.ilk │ │ │ ├── 5.obj │ │ │ ├── vc142.idb │ │ │ ├── vc142.pdb │ │ │ ├── 5.tlog │ │ │ │ ├── CL.read.1.tlog │ │ │ │ ├── CL.command.1.tlog │ │ │ │ ├── CL.write.1.tlog │ │ │ │ ├── link.read.1.tlog │ │ │ │ ├── link.write.1.tlog │ │ │ │ ├── link.command.1.tlog │ │ │ │ └── 5.lastbuildstate │ │ │ ├── 5.exe.recipe │ │ │ └── 5.log │ │ └── 5.vcxproj.user │ │ └── Debug │ │ ├── 5.exe │ │ └── 5.pdb ├── 6 │ └── 6 │ │ ├── 6 │ │ ├── Debug │ │ │ ├── 6.ilk │ │ │ ├── 6.obj │ │ │ ├── vc142.idb │ │ │ ├── vc142.pdb │ │ │ ├── 6.tlog │ │ │ │ ├── CL.read.1.tlog │ │ │ │ ├── CL.command.1.tlog │ │ │ │ ├── CL.write.1.tlog │ │ │ │ ├── link.read.1.tlog │ │ │ │ ├── link.write.1.tlog │ │ │ │ ├── link.command.1.tlog │ │ │ │ └── 6.lastbuildstate │ │ │ ├── 6.log │ │ │ └── 6.exe.recipe │ │ ├── 6.vcxproj.user │ │ └── 6.cpp │ │ └── Debug │ │ ├── 6.exe │ │ └── 6.pdb ├── 7 │ └── 7 │ │ ├── 7 │ │ ├── Debug │ │ │ ├── 7.log │ │ │ ├── 7.ilk │ │ │ ├── 7.obj │ │ │ ├── vc142.idb │ │ │ ├── vc142.pdb │ │ │ ├── 7.tlog │ │ │ │ ├── CL.read.1.tlog │ │ │ │ ├── CL.command.1.tlog │ │ │ │ ├── CL.write.1.tlog │ │ │ │ ├── link.read.1.tlog │ │ │ │ ├── link.write.1.tlog │ │ │ │ ├── link.command.1.tlog │ │ │ │ └── 7.lastbuildstate │ │ │ └── 7.exe.recipe │ │ └── 7.vcxproj.user │ │ └── Debug │ │ ├── 7.exe │ │ └── 7.pdb ├── 10 │ └── 10 │ │ ├── 10 │ │ ├── Debug │ │ │ ├── 10.ilk │ │ │ ├── 10.obj │ │ │ ├── vc142.idb │ │ │ ├── vc142.pdb │ │ │ ├── 10.tlog │ │ │ │ ├── CL.read.1.tlog │ │ │ │ ├── CL.write.1.tlog │ │ │ │ ├── CL.command.1.tlog │ │ │ │ ├── link.read.1.tlog │ │ │ │ ├── link.write.1.tlog │ │ │ │ ├── link.command.1.tlog │ │ │ │ └── 10.lastbuildstate │ │ │ ├── 10.log │ │ │ └── 10.exe.recipe │ │ └── 10.vcxproj.user │ │ └── Debug │ │ ├── 10.exe │ │ └── 10.pdb ├── readme ├── 4.2 │ └── 4.2 │ │ ├── 4.2 │ │ ├── Debug │ │ │ ├── 4.2.log │ │ │ ├── 4.2.ilk │ │ │ ├── 4.2.obj │ │ │ ├── vc142.idb │ │ │ ├── vc142.pdb │ │ │ ├── 4.2.tlog │ │ │ │ ├── CL.read.1.tlog │ │ │ │ ├── CL.write.1.tlog │ │ │ │ ├── link.read.1.tlog │ │ │ │ ├── CL.command.1.tlog │ │ │ │ ├── link.command.1.tlog │ │ │ │ ├── link.write.1.tlog │ │ │ │ └── 4.2.lastbuildstate │ │ │ └── 4.2.exe.recipe │ │ └── 4.2.vcxproj.user │ │ └── Debug │ │ ├── 4.2.exe │ │ └── 4.2.pdb ├── 10-2 │ ├── 10-2 │ │ ├── Debug │ │ │ ├── 10-2.log │ │ │ ├── 10-2.ilk │ │ │ ├── 10-2.obj │ │ │ ├── vc142.idb │ │ │ ├── vc142.pdb │ │ │ ├── 10-2.tlog │ │ │ │ ├── CL.read.1.tlog │ │ │ │ ├── CL.write.1.tlog │ │ │ │ ├── CL.command.1.tlog │ │ │ │ ├── link.read.1.tlog │ │ │ │ ├── link.write.1.tlog │ │ │ │ ├── link.command.1.tlog │ │ │ │ └── 10-2.lastbuildstate │ │ │ └── 10-2.exe.recipe │ │ └── 10-2.vcxproj.user │ └── Debug │ │ ├── 10-2.exe │ │ └── 10-2.pdb └── 16.cpp ├── 1411131055 └── 1 ├── 1411131057 └── readme ├── 1411131059 ├── readme ├── 字串提取浮點數 ├── 費氏數列Q2 ├── 字串出現次數 ├── Fibonacci ├── Array ├── 2.17 ├── 字串 ├── 2.16 ├── 綫性搜尋 ├── p153 └── Array Q2 ├── phillip0085 ├── readme ├── week2 ├── 1228ps2 s2出現在s1幾次 ├── 1228 ps3 榨甘蔗 ├── 0921HW17 速率 ├── 1026 p1 費伯納 ├── 1012 ps2 設計次方函數 ├── 1012 ps1 設計階乘分母函數 ├── 0921HW16 ├── 0928pset1 分數pass or fail ├── 1116 ps1 幾個星星 ├── 1228ps1-2大小寫互換 ├── 1116 ps2 學生餐廳評分統計 ├── 1019p1 random ├── 1228 ps1-1合成函數大小寫互換 ├── 1005p2 本金利率 ├── 1123 ps2 搜尋學生成績 └── 1123 ps1 泡泡成績排序 └── week ├── week10 ├── readme ├── README.md └── Practice 1 ├── week11 ├── readme ├── Response (Cognitive load) └── README.md ├── week12 ├── readme ├── Question 2 └── README.md ├── week13 ├── readme └── README.md ├── week14 ├── readme ├── README.md └── problem 2 ├── week15 ├── readme └── README.md ├── week16 ├── readme ├── README.md └── Problems 2 3 4 ├── week17 ├── readme └── Questionary (post) ├── week2 ├── readme ├── 0921第二題建議解.pdf ├── ch02(第二周投影片).pptx ├── 第二周練習題(兩題)題目.docx ├── README.md ├── Fig.02_02 └── Fig.02_05 ├── week3 ├── readme ├── README.md ├── ch3if_else └── Nest_if_else ├── week4 ├── readme ├── README.md └── p193practice(bouns) ├── week5 ├── readme ├── README.md ├── basic function call └── Factorial function ├── week6 ├── readme ├── Computer concept ├── README.md ├── practice └── Random Seed usage ├── week7 ├── readme ├── README.md ├── Practice └── Solution2 ├── week8 ├── readme ├── 1111_資管一1評量規準.xlsx └── README.md └── week9期中考 └── readme /1410931042/w6: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1410931042/ran: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1410931042/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411031012/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411031035/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411053034/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131001/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131003/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131005/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131007/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131009/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131011/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131015/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131017/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131019/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131021/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131025/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131027/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131029/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131031/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131033/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131035/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131037/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131039/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131041/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131043/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131045/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131047/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131049/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131053/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131057/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131059/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /phillip0085/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /phillip0085/week2: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week10/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week11/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week12/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week13/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week14/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week15/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week16/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week17/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week2/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week3/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week4/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week5/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week6/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week7/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week8/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week/week9期中考/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /1411131053/1/1/1/Debug/1.log: -------------------------------------------------------------------------------- 1 | 1.cpp 2 | 1.vcxproj -> C:\Users\User\Desktop\1\1\Debug\1.exe 3 | -------------------------------------------------------------------------------- /1411131053/3/3/3/Debug/3.log: -------------------------------------------------------------------------------- 1 | 3.cpp 2 | 3.vcxproj -> C:\Users\User\Desktop\3\3\Debug\3.exe 3 | -------------------------------------------------------------------------------- /1411131053/4/4/4/Debug/4.log: -------------------------------------------------------------------------------- 1 | 4.cpp 2 | 4.vcxproj -> C:\Users\User\Desktop\4\4\Debug\4.exe 3 | -------------------------------------------------------------------------------- /1411131053/7/7/7/Debug/7.log: -------------------------------------------------------------------------------- 1 | 7.cpp 2 | 7.vcxproj -> C:\Users\user\Desktop\7\7\Debug\7.exe 3 | -------------------------------------------------------------------------------- /1411131053/4.2/4.2/4.2/Debug/4.2.log: -------------------------------------------------------------------------------- 1 | 4.2.cpp 2 | 4.2.vcxproj -> C:\Users\user\Desktop\4.2\4.2\Debug\4.2.exe 3 | -------------------------------------------------------------------------------- /1411131053/10-2/10-2/Debug/10-2.log: -------------------------------------------------------------------------------- 1 | 10-2.cpp 2 | 10-2.vcxproj -> C:\Users\User\Desktop\10-2\10-2\Debug\10-2.exe 3 | -------------------------------------------------------------------------------- /1411131047/0921216.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chendannytw/111-1-4year-undergraduateC-C-program/HEAD/1411131047/0921216.cpp -------------------------------------------------------------------------------- /1411131021/W6-3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 2 | #include C:\Users\User\Desktop\10\10\Debug\10.exe 4 | -------------------------------------------------------------------------------- /1411131053/10/10/10/Debug/10.tlog/link.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chendannytw/111-1-4year-undergraduateC-C-program/HEAD/1411131053/10/10/10/Debug/10.tlog/link.command.1.tlog -------------------------------------------------------------------------------- /1411131053/4.2/4.2/4.2/Debug/4.2.tlog/CL.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chendannytw/111-1-4year-undergraduateC-C-program/HEAD/1411131053/4.2/4.2/4.2/Debug/4.2.tlog/CL.write.1.tlog -------------------------------------------------------------------------------- /1411131053/4.2/4.2/4.2/Debug/4.2.tlog/link.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chendannytw/111-1-4year-undergraduateC-C-program/HEAD/1411131053/4.2/4.2/4.2/Debug/4.2.tlog/link.read.1.tlog -------------------------------------------------------------------------------- /1411131053/10-2/10-2/Debug/10-2.tlog/link.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chendannytw/111-1-4year-undergraduateC-C-program/HEAD/1411131053/10-2/10-2/Debug/10-2.tlog/link.command.1.tlog -------------------------------------------------------------------------------- /1411131053/4.2/4.2/4.2/Debug/4.2.tlog/CL.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chendannytw/111-1-4year-undergraduateC-C-program/HEAD/1411131053/4.2/4.2/4.2/Debug/4.2.tlog/CL.command.1.tlog -------------------------------------------------------------------------------- /1411131053/4.2/4.2/4.2/Debug/4.2.tlog/link.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chendannytw/111-1-4year-undergraduateC-C-program/HEAD/1411131053/4.2/4.2/4.2/Debug/4.2.tlog/link.command.1.tlog -------------------------------------------------------------------------------- /1411131053/4.2/4.2/4.2/Debug/4.2.tlog/link.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chendannytw/111-1-4year-undergraduateC-C-program/HEAD/1411131053/4.2/4.2/4.2/Debug/4.2.tlog/link.write.1.tlog -------------------------------------------------------------------------------- /1411131053/1/1/1/1.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /1411131053/2/2/2/2.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /1411131053/3/3/3/3.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /1411131053/4/4/4/4.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /1411131053/5/5/5/5.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /1411131053/6/6/6/6.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /1411131053/7/7/7/7.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /1411131053/10/10/10/10.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /1411131053/3/3/3/Debug/3.tlog/3.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: 2 | Debug|Win32|C:\Users\User\Desktop\3\3\| 3 | -------------------------------------------------------------------------------- /1411131053/4/4/4/Debug/4.tlog/4.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: 2 | Debug|Win32|C:\Users\User\Desktop\4\4\| 3 | -------------------------------------------------------------------------------- /1411131053/5/5/5/Debug/5.tlog/5.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: 2 | Debug|Win32|C:\Users\user\Desktop\5\5\| 3 | -------------------------------------------------------------------------------- /1411131053/6/6/6/Debug/6.log: -------------------------------------------------------------------------------- 1 | 6.cpp 2 | C:\Users\user\Desktop\6\6\6\6.cpp(14,17): warning C4244: '=': 將 'double' 轉換為 'unsigned int',由於類型不同,可能導致資料遺失 3 | 6.vcxproj -> C:\Users\user\Desktop\6\6\Debug\6.exe 4 | -------------------------------------------------------------------------------- /1411131053/6/6/6/Debug/6.tlog/6.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: 2 | Debug|Win32|C:\Users\user\Desktop\6\6\| 3 | -------------------------------------------------------------------------------- /1411131053/7/7/7/Debug/7.tlog/7.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: 2 | Debug|Win32|C:\Users\user\Desktop\7\7\| 3 | -------------------------------------------------------------------------------- /1411131053/10-2/10-2/10-2.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /1411131053/10/10/10/Debug/10.tlog/10.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: 2 | Debug|Win32|C:\Users\User\Desktop\10\10\| 3 | -------------------------------------------------------------------------------- /1411131053/4.2/4.2/4.2/4.2.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /week/week6/practice: -------------------------------------------------------------------------------- 1 | 10/19 2 | 題目1(max 90 points): 輸入整數n<5,要傳回10n組亂數,亂數值介於0.9999…9~0.0000...1, n為精確值(小數後第幾位 (要用使用者自訂函數) 3 | n =1產生10組 0.1~0.9 之間的亂數, n=3產生10組 0.001~0.999 (印出的亂數五個一列,要盡量滿足均勻分布uniform distribution) 4 | -------------------------------------------------------------------------------- /1411131053/10-2/10-2/Debug/10-2.tlog/10-2.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: 2 | Debug|Win32|C:\Users\User\Desktop\10-2\10-2\| 3 | -------------------------------------------------------------------------------- /1411131053/4.2/4.2/4.2/Debug/4.2.tlog/4.2.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: 2 | Debug|Win32|C:\Users\user\Desktop\4.2\4.2\| 3 | -------------------------------------------------------------------------------- /week/week13/README.md: -------------------------------------------------------------------------------- 1 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/ZcbHbbgVc-I/0.jpg)](https://www.youtube.com/watch?v=ZcbHbbgVc-I "翻轉課程-指標") 2 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/YkisfkUE4DA/0.jpg)](https://www.youtube.com/watch?v=YkisfkUE4DA "課後補充-指標") 3 | -------------------------------------------------------------------------------- /week/week11/README.md: -------------------------------------------------------------------------------- 1 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/zfZvADUorL8/0.jpg)](https://www.youtube.com/watch?v=zfZvADUorL8 "翻轉教學-排序與搜尋") 2 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/eEfTN3U8isE/0.jpg)](https://www.youtube.com/watch?v=eEfTN3U8isE "課後補充-排序與線性搜尋") 3 | -------------------------------------------------------------------------------- /week/week12/README.md: -------------------------------------------------------------------------------- 1 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/WEh2MvHzwks/0.jpg)](https://www.youtube.com/watch?v=WEh2MvHzwks "翻轉教學-二元搜尋、二維陣列") 2 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/hCn2uXsFhsI/0.jpg)](https://www.youtube.com/watch?v=hCn2uXsFhsI "課後補充-二元搜尋") 3 | -------------------------------------------------------------------------------- /week/week2/Fig.02_02: -------------------------------------------------------------------------------- 1 | // Printing on one line with two printf statements 2 | #include 3 | 4 | // function main begins program execution 5 | int main( void ) 6 | { 7 | printf( "Welcome " ); 8 | printf( "to C!\n" ); 9 | } // end function main 10 | -------------------------------------------------------------------------------- /week/week4/README.md: -------------------------------------------------------------------------------- 1 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/KYyPFfTrzfk/0.jpg)](https://www.youtube.com/watch?v=KYyPFfTrzfk "C語言程式設計第四周") 2 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/nRaDVuKG4RE/0.jpg)](https://www.youtube.com/watch?v=nRaDVuKG4RE "C語言程式設計第四周2") 3 | -------------------------------------------------------------------------------- /week/week10/README.md: -------------------------------------------------------------------------------- 1 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/n1dnXJYij6I/0.jpg)](https://www.youtube.com/watch?v=n1dnXJYij6I "翻轉教學-陣列的使用") 2 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/FeNTdhGOZ4s/0.jpg)](https://www.youtube.com/watch?v=FeNTdhGOZ4s "課後補充-陣列使用與副程式傳遞陣列") 3 | -------------------------------------------------------------------------------- /week/week14/README.md: -------------------------------------------------------------------------------- 1 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/T7w109e6TdY/0.jpg)](https://www.youtube.com/watch?v=T7w109e6TdY "翻轉課程-指標與const保留字的用法與複習") 2 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/3VLYw-fS6nM/0.jpg)](https://www.youtube.com/watch?v=3VLYw-fS6nM "課後補充-常數與指標混和應用") 3 | -------------------------------------------------------------------------------- /1411131047/0921217.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int v1,v2, a1, t,asw; 5 | scanf_s("%d", &v1); 6 | scanf_s("%d", &a1); 7 | scanf_s("%d", &t); 8 | v2 = v1 + a1 * t; 9 | asw = v2 * t + a1 * t * t / 2; 10 | printf("%d", asw); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /week/week15/README.md: -------------------------------------------------------------------------------- 1 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/uBcfaUWUUpo/0.jpg)](https://www.youtube.com/watch?v=uBcfaUWUUpo "翻轉課程-指標算術運算與指標陣列") 2 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/kRr-NYpSLJg/0.jpg)](https://www.youtube.com/watch?v=kRr-NYpSLJg "課後補充-指標陣列、函數指標、sizeof()使用") 3 | -------------------------------------------------------------------------------- /1411131039/1116: -------------------------------------------------------------------------------- 1 | #include 2 | #define size 10 3 | 4 | int a(int c[size]); 5 | int main(void) { 6 | int n[size]={2,2,5,9,4,6,7,8,3,1}; 7 | int c[11]={0}; 8 | printf("%s%13s%17s\n","Element","value","bar Chart"); 9 | for(i=0,i 2 | #include 3 | #include 4 | 5 | int main() { 6 | char s1[10] = "ABABEABDt", s2[3] = "AB"; 7 | int i, time=0; 8 | for (i=0; i < 7; i++) { 9 | if (strncmp(s2, s1+ i, 2) == 0) time++; 10 | } 11 | printf_s("%d", time); 12 | } -------------------------------------------------------------------------------- /1411131039/1026Q1: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int f(int); 4 | int main(void) { 5 | 6 | int n; 7 | printf("輸入一項:"); 8 | scanf("%d",&n); 9 | printf("數值為:%d",f(n)); 10 | } 11 | f(int n){ 12 | if(n<=1){ 13 | return n; 14 | } 15 | else{ 16 | return f(n-1)+f(n-2); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /phillip0085/1228ps2 s2出現在s1幾次: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | char s1[17] = "abcdefababcdefgh"; 4 | char s2[] = "def"; 5 | 6 | int num = 0; 7 | 8 | for (int i = 0; i < 17; i++) 9 | { 10 | if (strncmp(s2, s1 + i, 3) == 0) 11 | { 12 | num++; 13 | } 14 | } 15 | 16 | printf("%s在%s出現的次數為%d個", s2, s1, num); 17 | } 18 | -------------------------------------------------------------------------------- /1411031035/week 7: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int f(int n) 5 | { 6 | if (n <= 1 ) 7 | { 8 | return n; 9 | } 10 | else 11 | { 12 | return f(n - 1) + f(n - 2); 13 | } 14 | 15 | } 16 | 17 | int main() 18 | { 19 | int n; 20 | printf("請輸入值\n"); 21 | scanf("%d", &n ); 22 | 23 | printf("值為%d", f(n)); 24 | } 25 | -------------------------------------------------------------------------------- /1411131033/week7: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int f(int n) 5 | { 6 | if (n <= 1 ) 7 | { 8 | return n; 9 | } 10 | else 11 | { 12 | return f(n - 1) + f(n - 2); 13 | } 14 | 15 | } 16 | 17 | int main() 18 | { 19 | int n; 20 | printf("請輸入值\n"); 21 | scanf("%d", &n ); 22 | 23 | printf("值為%d", f(n)); 24 | } 25 | -------------------------------------------------------------------------------- /1411131039/20220921: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) 3 | { 4 | int integer1; 5 | int integer2; 6 | printf("enter first integer\n"); 7 | scanf_s("%d", &integer1); 8 | printf("enter second integer\n"); 9 | scanf_s("%d", &integer2); 10 | int sum=integer1 + integer2; 11 | printf("Sum is %d\n", sum); 12 | } 13 | -------------------------------------------------------------------------------- /1411131053/1/1/1/Debug/1.exe.recipe: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | C:\Users\User\Desktop\1\1\Debug\1.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /1411131053/3/3/3/Debug/3.exe.recipe: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | C:\Users\User\Desktop\3\3\Debug\3.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /1411131053/4/4/4/Debug/4.exe.recipe: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | C:\Users\User\Desktop\4\4\Debug\4.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /1411131053/5/5/5/Debug/5.exe.recipe: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | C:\Users\user\Desktop\5\5\Debug\5.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /1411131053/6/6/6/Debug/6.exe.recipe: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | C:\Users\user\Desktop\6\6\Debug\6.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /1411131053/7/7/7/Debug/7.exe.recipe: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | C:\Users\user\Desktop\7\7\Debug\7.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /1411131053/10/10/10/Debug/10.exe.recipe: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | C:\Users\User\Desktop\10\10\Debug\10.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /week/week14/problem 2: -------------------------------------------------------------------------------- 1 | 題目 1: (max. 95)建立一個10*3整數陣列以及一個指標陣列name,將全班10人的學號,數學成績,計概成績放入整數陣列中(可直接置於程式內),將全班10人的姓名放入指標陣列中。根據每個學生的總分,由大到小排序,印出美觀的全班成績表,並印出各科眾數。需使用副程式,字串交換副程式需使用p.333的拷貝副程式完成。 2 | Bonus : 承上題,由鍵盤輸入學號,印出該名學生的成績表(包含姓名、總分、名次),需有搜尋副程式,報表務求美觀、大方。 3 | 題目 2: (max. 65)建立二個指標陣列name1、name2,透過鍵盤輸入將全班10人的姓名放入指標陣列name1中,需使用字串交換副程式(p.333),將name1的內容複製到name2,最後以副程式列印陣列內容。 4 | -------------------------------------------------------------------------------- /1411131023/week16 P2: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | int main() 5 | { 6 | char s1[17] = "abcdefababcdefgh"; 7 | char s2[] = "def"; 8 | int num = 0; 9 | for (int i = 0; i < 16; i++) 10 | { 11 | if (strncmp(s2, s1 + i, 3) == 0) 12 | { 13 | num++; 14 | } 15 | } 16 | printf("%s在%s出現的次數為%d個\n", s2, s1, num); 17 | } 18 | -------------------------------------------------------------------------------- /1411131053/4.2/4.2/4.2/Debug/4.2.exe.recipe: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | C:\Users\user\Desktop\4.2\4.2\Debug\4.2.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /1411131053/10-2/10-2/Debug/10-2.exe.recipe: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | C:\Users\User\Desktop\10-2\10-2\Debug\10-2.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /1411131047/22-12-28-3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | char s1[] = "abc2.34ababc3.8gh4.4xyz"; 7 | char*s1Ptr = &s1[0]; 8 | while (*s1Ptr != '\0') 9 | { 10 | if (isdigit(*s1Ptr)) { 11 | double d = strtod(s1Ptr, &s1Ptr); 12 | printf("%.2f ,",d); 13 | } 14 | else s1Ptr++; 15 | } 16 | } -------------------------------------------------------------------------------- /week/week16/Problems 2 3 4: -------------------------------------------------------------------------------- 1 | 題目一 2 | 給定一個字串,先計算且印出字串中的大、小寫與數字的數量,之後將字串中的大、小寫互換之後,再將互換後的字串印出。 3 | 4 | 題目二 5 | 給定兩個字串s1與s2,找出s2在s1出現的次數並印出。(請使用strncmp、strstr函數) 6 | 範例: 7 | s1 = “abcdefababcdefgh” 8 | s2 = “def” 9 | 10 | 印出2 11 | 12 | 題目三 13 | 寫一個程式,能將字串中一個或多個浮點數取出,並且分別印出。Hint: strtod()、strncat() 14 | 範例: 15 | s1 = “abc2.34ababc3.8gh4.4xyz” 16 | 17 | 印出2.34 18 | 3.8 19 | 4.4 20 | -------------------------------------------------------------------------------- /1411131039/1012Q1: -------------------------------------------------------------------------------- 1 | #include 2 | double expo(int); 3 | int main(void){ 4 | int x; 5 | for (x = 1; x <= 10; x++) { 6 | printf(" value of e is :%f\n",expo(x)); 7 | } 8 | } 9 | double expo(int y){ 10 | double result=1,i; 11 | double expo=1; 12 | 13 | for(i=1;i<=y;i++){ 14 | result=result*i; 15 | expo=expo+(1/result); 16 | } 17 | return expo; 18 | } 19 | -------------------------------------------------------------------------------- /1411131039/1012Q2: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | int power(int x,int y); 5 | int main(void) { 6 | int x,y; 7 | printf("請輸入底數:"); 8 | scanf("%d",&x); 9 | printf("\n請輸入次方:"); 10 | scanf("%d",&y); 11 | printf("\n數值為:%d",power(x,y)); 12 | } 13 | int power(x,y){ 14 | int z=1,i; 15 | for(i=1;i<=y;i++){ 16 | z=z*x; 17 | } 18 | return z; 19 | } 20 | -------------------------------------------------------------------------------- /1411131017/week7 遞迴: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fibonacci(int n); 4 | 5 | int main(void) 6 | { 7 | int n; 8 | printf("enter a number:\n"); 9 | scanf_s("%d",&n); 10 | printf("result=%d\n", fibonacci(n)); 11 | } 12 | 13 | int fibonacci(int n) { 14 | if (0 == n || 1 == n) { 15 | return n; 16 | } 17 | else { 18 | return fibonacci(n - 1) + fibonacci(n - 2); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /1411131039/1228Q2: -------------------------------------------------------------------------------- 1 | //兩字串在s1找出s2字串的出現次數並印出 2 | #include 3 | #include 4 | #include 5 | int main() { 6 | char s1[17]="abcdefababcdefgh"; 7 | char s2[17]="def"; 8 | int cnt=0; 9 | printf("原始字串:%s\n",s1); 10 | printf("找尋字串:%s\n",s2); 11 | int i; 12 | for(i=0;i<16;i++){ 13 | if(strncmp(s2,s1+i,3)==0) 14 | cnt++; 15 | } 16 | printf("出現次數為:%d",cnt); 17 | } 18 | -------------------------------------------------------------------------------- /1411131059/字串提取浮點數: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | char s1[] = "abc2.34ababc3.8gh4.4xyz"; 8 | char* s1Ptr = &s1[0]; 9 | while (*s1Ptr!='\0') 10 | { 11 | if (!isdigit(*s1Ptr)) 12 | { 13 | s1Ptr++; 14 | } 15 | else 16 | { 17 | double d = strtod(s1Ptr, &s1Ptr); 18 | printf("%.2f\n", d); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /1411131059/費氏數列Q2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n,f,n1,n2; 6 | printf("Enter n: "); 7 | scanf("%u",&n); 8 | n1=0; 9 | n2=1; 10 | if(n==0 || n==1){ 11 | printf("%d",n); 12 | } 13 | else{ 14 | for(int i=2 ; i<=n ; ++i){ 15 | f=n1+n2; 16 | n1=n2; 17 | n2=f; 18 | printf("%d ",f); 19 | } 20 | } 21 | printf("\n%d",f); 22 | } 23 | -------------------------------------------------------------------------------- /1411131001/week6 第一題: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int fibonacci(int n); 5 | int main(void) 6 | { 7 | int n; 8 | printf("please input a number:\n "); 9 | scanf_s("%d", &n); 10 | printf("result = %d\n ", fibonacci(n)); 11 | } 12 | 13 | int fibonacci(int n){ 14 | if (0 == n || 1 == n) { 15 | return n; 16 | } 17 | else { 18 | return fibonacci(n - 1) + fibonacci(n - 2); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /1411131023/week 16 P3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void) { 6 | int cnt = 0, i; 7 | 8 | char s1[] = "abc2.34ababc3.8gh4.4xyz"; 9 | char* s1Ptr = &s1[0]; 10 | 11 | while (*s1Ptr != '\0') { 12 | if (!isdigit(*s1Ptr)) { 13 | s1Ptr++; 14 | } 15 | else { 16 | double d = strtod(s1Ptr, &s1Ptr); 17 | printf("%.2f\n", d); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /1411131059/字串出現次數: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define SIZE 18 4 | 5 | int main(void) 6 | { 7 | int cnt = 0; 8 | char s1[SIZE] = "abcdefabcabcdefgh"; 9 | char s2[SIZE] = "def"; 10 | 11 | for (int i = 0; i < SIZE - 1; i++) 12 | { 13 | if (strncmp(s2, s1 + i, 3)==0) 14 | { 15 | cnt += 1; 16 | } 17 | } 18 | printf("%s appear in %s : %d times",s2,s1,cnt); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /1411131039/0921Q1: -------------------------------------------------------------------------------- 1 | int main() { 2 | int n1; 3 | int n2; 4 | printf("enter first integer\n"); 5 | scanf_s("%d",&n1); 6 | printf("enter second integer\n"); 7 | scanf_s("%d",&n2); 8 | int sum,a,b,c,m; 9 | sum=n1+n2; 10 | a=n1-n2; 11 | b=n1*n2; 12 | c=n1/n2; 13 | m=n1%n2; 14 | printf("和為%d\n",sum); 15 | printf("差為%d\n",a); 16 | printf("乘積為%d\n",b); 17 | printf("商為%d\n",c); 18 | printf("餘數為%d\n",m); 19 | } 20 | -------------------------------------------------------------------------------- /1411131053/16.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char* argv[]) 6 | { 7 | 8 | int i=0; 9 | char word[10]; 10 | scanf("%19s",word); 11 | printf("\n %s", word); 12 | while (word[i]!='\0') 13 | { word[i]=toupper(word[i]); 14 | i++; 15 | } 16 | printf("\n %s", word); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /1411131039/1019Q1: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | int main(void){ 5 | int n,m,temp,i; 6 | srand(n); 7 | printf("請輸入整數1~5,其中一個數值:"); 8 | scanf("%u",&n); 9 | for(i=1;i<=pow(10,n);++i){ 10 | temp=pow(10,n); 11 | m=rand()%temp; 12 | printf("%.5f  ",(double)m / pow(10,n)); 13 | if(i%5==0) 14 | puts(""); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /1411131049/w16 q2: -------------------------------------------------------------------------------- 1 | //給定兩個字串s1與s2,找出s2在s1出現的次數並印出。(請使用strncmp、strstr函數) 2 | #include 3 | #include 4 | #include 5 | 6 | int main() { 7 | char s1[17]="abcdefababcdefgh"; 8 | char s2[17]="def"; 9 | int cnt=0; 10 | printf("原始字串:%s\n",s1); 11 | printf("找尋字串:%s\n",s2); 12 | int i; 13 | for(i=0;i<16;i++){ 14 | if(strncmp(s2,s1+i,3)==0) 15 | cnt++; 16 | } 17 | printf("出現次數為:%d",cnt); 18 | } 19 | -------------------------------------------------------------------------------- /1411131053/5/5/5/Debug/5.log: -------------------------------------------------------------------------------- 1 | 5.cpp 2 | C:\Users\user\Desktop\5\5\5\5.cpp(17,9): warning C4477: 'printf' : 格式字串 '%lf' 需要 'double' 類型的引數,但 variadic 引數 1 的類型為 'double (__cdecl *)(int,int)' 3 | C:\Users\user\Desktop\5\5\5\5.cpp(18,14): warning C4244: 'return': 將 'double' 轉換為 'int',由於類型不同,可能導致資料遺失 4 | C:\Users\user\Desktop\5\5\5\5.cpp(46): warning C4717: 'power': 在所有控制路徑上遞迴,函式將導致執行階段堆疊溢位 5 | 5.vcxproj -> C:\Users\user\Desktop\5\5\Debug\5.exe 6 | -------------------------------------------------------------------------------- /week/week5/README.md: -------------------------------------------------------------------------------- 1 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/U3sSsTlQkMQ/0.jpg)](https://www.youtube.com/watch?v=U3sSsTlQkMQ "C語言程式設計第五周(大學版1)庫存函數與使用者定義函數") 2 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/FxJr_KYjqgs/0.jpg)](https://www.youtube.com/watch?v=FxJr_KYjqgs "C語言程式設計第五周(大學版2)庫存函數與使用者定義函數") 3 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/O_qSjtw7jgs/0.jpg)](https://www.youtube.com/watch?v=O_qSjtw7jgs "C語言程式設計第五周(大學版3)庫存函數與使用者定義函數") 4 | -------------------------------------------------------------------------------- /1411131007/week2-2: -------------------------------------------------------------------------------- 1 | int main() { 2 | int v; 3 | int a; 4 | int e; 5 | 6 | printf("物體速度v\n"); 7 | scanf("%d",&v); 8 | 9 | printf("加速度a\n"); 10 | scanf("%d",&a); 11 | 12 | printf("經過時間e\n"); 13 | scanf("%d",&e); 14 | 15 | int V; 16 | V=v+a*e; 17 | printf("v is %d\n",v); 18 | 19 | int f; 20 | f=v*e+1/2*a*e*e; 21 | printf("f is %d\n",f); 22 | } 23 | -------------------------------------------------------------------------------- /1411131039/0921Q2: -------------------------------------------------------------------------------- 1 | #include 2 | /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 3 | int main(void) { 4 | int v,a,e; 5 | printf("請輸入物體速度:"); 6 | scanf("%d",&v); 7 | printf("請輸入加速度:"); 8 | scanf("%d",&a); 9 | printf("請輸入經過時間:"); 10 | scanf("%d",&e); 11 | v=v+a*e; 12 | int s; 13 | int m; 14 | s=v*e+(a*e*e)/2; 15 | printf("最後速度為:%d\n",v); 16 | printf("移動距離為:%d\n",s); 17 | } 18 | -------------------------------------------------------------------------------- /1411131011/week7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unsigned long long int f(unsigned int number); 4 | 5 | int main(void) 6 | { 7 | unsigned int n; 8 | printf( "Enter a number:"); 9 | scanf_s("%d", &n); 10 | 11 | printf("第n項是:%d\n" ,f(n-1)); 12 | } 13 | 14 | unsigned long long int f(unsigned int number) 15 | { 16 | if (number == 0 or number == 1) { 17 | return number; 18 | } 19 | else { 20 | return(f(number - 1) + f(number - 2)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /1411131035/week2物理速度計算: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int v;//物體速度 6 | int a;//加速度 7 | int e;//經過時間 8 | 9 | printf("物體速度v\n"); 10 | scanf_s("%d", &v); 11 | printf("加速度a\n"); 12 | scanf_s("%d", &a); 13 | printf("經過時間e\n"); 14 | scanf_s("%d", &e); 15 | 16 | int v2 = v + a * e; 17 | printf("\n最後速度=%d",v2); 18 | int s = v * e + a * e *e / 2; 19 | printf("\n移動距離=%d",s); 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /1411131003/week7 (1): -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unsigned long long int f(unsigned int number); 4 | 5 | int main(void) 6 | { 7 | unsigned int n; 8 | printf("please enter n:"); 9 | scanf_s("%d",&n); 10 | 11 | printf("第n項:%d\n", f(n - 1)); 12 | } 13 | 14 | 15 | unsigned long long int f(unsigned int number) 16 | { 17 | if (number == 0 or number ==1) { 18 | return number; 19 | } 20 | else { 21 | return (f(number - 1) + f(number - 2)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /1411131037/week6: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { unsigned int i; 6 | unsigned int n,m,temp; 7 | 8 | printf("enter n (n<5) : "); 9 | scanf("%u", &n); 10 | 11 | srand(n); 12 | 13 | for( i=1; i<=pow(10,n); ++i) { 14 | temp=pow(10,n); 15 | m=rand()%temp; 16 | 17 | printf("%10lf", (double)m/pow(10,n)); 18 | 19 | if( i % 5 ==0 ) { 20 | puts(""); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /1411131047/22-12-28-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | char s1[10] = "Hello",word; 6 | int upr=0, low=0,i=0; 7 | while (s1[i]!='\0') 8 | { 9 | if (islower(s1[i])) { 10 | low++; 11 | word=toupper(s1[i]); 12 | } 13 | if (isupper(s1[i])) { 14 | upr++; 15 | word = tolower(s1[i]); 16 | } 17 | printf_s("%c",word); 18 | i++; 19 | } 20 | 21 | printf_s("\nupper:%d,lower:%d", upr, low); 22 | } -------------------------------------------------------------------------------- /phillip0085/1228 ps3 榨甘蔗: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | int main() 8 | { 9 | char s1[] = "abc2.34ababc3.8gh4.4xyz"; 10 | char* s1Ptr = &s1[0]; 11 | 12 | while (*s1Ptr != '\0') { 13 | if (!isdigit(*s1Ptr)) { 14 | s1Ptr++; //非數字就繼續往下看是不是 15 | } 16 | else { 17 | double d = strtod(s1Ptr, &s1Ptr); //是數字就把string轉成double輸出 18 | printf("%.2f\n", d); 19 | 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /1411131047/22-11-16-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define size1 5 3 | 4 | void Bar(int); 5 | 6 | int main(){ 7 | int ar[size1] = {19,3,15,7,11 }; 8 | printf_s("%s%13s%17s\n","Element","Value","Bar Chart"); 9 | for (int i = 0; i < size1; i++) { 10 | printf_s("%7d%13d%8s",i,ar[i],""); 11 | Bar(ar[i]); 12 | } 13 | 14 | 15 | } 16 | 17 | void Bar(int n) { 18 | for (int i = 0; i < n; i++) { 19 | printf_s("*"); 20 | } 21 | puts(""); 22 | } 23 | -------------------------------------------------------------------------------- /1411131009/1228-2: -------------------------------------------------------------------------------- 1 | //給定兩個字串s1、s2,找出s2在s1出現的次數並印出(請使用strncmp、strstr函數) 2 | //s1=abcdefababcdefgh; s2=de 3 | 4 | #include 5 | 6 | int main() 7 | { 8 | int i = 0, a = 0; 9 | char s1[14] = "ABcdEfABCcdeF"; 10 | char s2[3] = "cd"; 11 | for (i = 0; i < 13; i++) { 12 | if (strncmp(s2, s1 + i, 2) == 0) //比較s2和s1+i的連續2個字元是否相等 13 | a += 1; //若相等則a+1 14 | } 15 | printf("s1:ABcdEfABCdeF\n"); 16 | printf("s2:cd\n"); 17 | printf("s2在s1出現%d次", a); 18 | } 19 | -------------------------------------------------------------------------------- /1411131039/1228Q3: -------------------------------------------------------------------------------- 1 | //將字串多個浮點數取出並印出 2 | #include 3 | #include 4 | #include 5 | #include 6 | int main() { 7 | char *s1="ab3.14159cdefaba2.295bcde5.46fgh"; 8 | char *nptr=""; 9 | printf("原始字串:%s\n",s1); 10 | int i=0; 11 | while(i 2 | 3 | int main(void) 4 | { 5 | int v; 6 | int a; 7 | int e; 8 | 9 | printf("物體速度v\n"); 10 | scanf_s("%d", &v); 11 | 12 | printf("加速度a\n"); 13 | scanf_s("%d", &a); 14 | 15 | printf("經過時間e\n"); 16 | scanf_s("%d", &e); 17 | 18 | int V; 19 | V = v + a*e; 20 | printf("v is % d\n", v); 21 | 22 | int s; 23 | s = v * e + 1 / 2 * a * e * e; 24 | printf("s is % d\n", s); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /1411131049/w16 q3: -------------------------------------------------------------------------------- 1 | //寫一個程式,能將字串中一個或多個浮點數取出,並且分別印出。 2 | #include 3 | #include 4 | #include 5 | #include 6 | int main() { 7 | char *s1="abc2.34ababc3.8gh4.4xyz"; 8 | char *nptr=""; 9 | printf("原始字串:%s\n",s1); 10 | int i=0; 11 | while(i 4 | #include 5 | #include 6 | 7 | int main(void) 8 | { 9 | unsigned int n, m, temp,i; 10 | printf("enter n:"); 11 | scanf_s("%u", &n); 12 | 13 | srand(n); 14 | 15 | for (i = 1; i <= 10000; ++i) { 16 | temp = pow(10, n); 17 | m = rand() % temp; 18 | 19 | printf("%.10f", (double)m / pow(10, n)); 20 | 21 | if (i % 5 == 0) 22 | puts(""); 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /1411131007/week16-2: -------------------------------------------------------------------------------- 1 | 題目二 2 | 給定兩個字串s1與s2,找出s2在s1出現的次數並印出。(請使用strncmp、strstr函數) 3 | 範例: 4 | s1 = “abcdefababcdefgh” 5 | s2 = “def” 6 | 7 | #include 8 | #include 9 | 10 | int main (void){ 11 | int cnt = 0, i; 12 | 13 | char s1[13] = "ABcdEFABCdeF"; 14 | char s2[13] = "AB"; 15 | 16 | for (i = 0; i < 12; i++ ) { 17 | if (strncmp (s2, s1 + i, 2) == 0) 18 | cnt += 1; 19 | } 20 | 21 | printf ("%s 在 %s 出現的次數為 %d", s2, s1, cnt); 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /1411131007/week6: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void) 6 | {unsigned int i; 7 | unsigned int n,m,temp; 8 | 9 | printf("Enter n: "); 10 | scanf("%u", &n); 11 | 12 | srand(n); 13 | 14 | for (i = 1; i <=pow(10,n); ++i) { 15 | temp=pow(10,n); 16 | m=rand()%temp; 17 | 18 | printf("%10lf",(double)m/pow(10,n)); 19 | 20 | if (i % 5 == 0) { 21 | puts(""); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /1411131041/week2: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) 3 | { 4 | printf("Welcome to C!\n"); 5 | } 6 | ---------------------------------------------- 7 | #include 8 | 9 | int main(void) 10 | { 11 | int integer1; 12 | int integer2; 13 | 14 | printf("Enter first integer\n"); 15 | 16 | scanf_s("%d", & integer1); 17 | 18 | printf("Enter secpmd integer\n"); 19 | scanf_s("%d", & integer2); 20 | 21 | int sum; 22 | sum = integer1 + integer2; 23 | printf("Sum is %d\n", sum); 24 | } 25 | -------------------------------------------------------------------------------- /1411131059/Fibonacci: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unsigned long long int f(unsigned int n); 4 | 5 | int main(void) 6 | { 7 | unsigned int n; 8 | printf("%s","Enter n: "); 9 | scanf("%u", &n); 10 | 11 | unsigned long long int result = f(n); 12 | printf("Fibonacci(%u) = %llu\n", n, result); 13 | } 14 | 15 | unsigned long long int f(unsigned int n) 16 | { 17 | if (n == 0 || n == 1) 18 | { 19 | return n; 20 | } 21 | else{ 22 | return f(n - 1) + f(n - 2); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /phillip0085/1026 p1 費伯納: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | unsigned long long int f(unsigned int number) ; 5 | 6 | int main() 7 | { 8 | unsigned int n; 9 | printf("Please enter n:"); 10 | scanf_s("%d", &n); 11 | 12 | printf("第n項:%d\n", f(n-1)); 13 | } 14 | 15 | 16 | 17 | unsigned long long int f(unsigned int number) 18 | { 19 | if (number == 0 or number == 1) { 20 | return number; 21 | } 22 | else { 23 | return (f(number - 1) + f(number - 2)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /1411131001/week16 Q2: -------------------------------------------------------------------------------- 1 | /*題目二 2 | 給定兩個字串s1與s2,找出s2在s1出現的次數並印出。(請使用strncmp、strstr函數) 3 | 範例: 4 | s1 = “abcdefababcdefgh” 5 | s2 = “def”*/ 6 | 7 | 8 | #include 9 | #include 10 | 11 | int main(void) { 12 | 13 | int cnt = 0; 14 | char s1[13] = "ABcdEfABCdeF"; 15 | char s2[13] = "AB"; 16 | for (int i = 0; i < 12; i++) { 17 | if (strncmp(s2, s1 + i, 2) == 0) 18 | cnt += 1; 19 | } 20 | printf("%s在%s出現的次數:%d個",s2, s1, cnt); 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /1411131049/w7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unsigned long long int f(unsigned int n); 4 | 5 | int main(void) 6 | { 7 | unsigned int n; 8 | printf("%s","enter n :"); 9 | scanf("%d",&n); 10 | 11 | unsigned long long int result = f(n); 12 | printf("Fibonnacci(%u) = %11u\n",n,result); 13 | } 14 | 15 | unsigned long long int f(unsigned int n) 16 | { 17 | 18 | if (n == 0 || n == 1 ) 19 | { 20 | 21 | return n; 22 | } 23 | else{ 24 | 25 | return f(n-1)+f(n-2); 26 | 27 | } 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /phillip0085/1012 ps2 設計次方函數: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | double power(int, int); 5 | 6 | int main(void) 7 | { 8 | int x; 9 | printf("Please enter x:\n"); 10 | scanf_s("%d", &x); 11 | printf("Please enter y:\n"); 12 | scanf_s("%d", &y); 13 | 14 | printf("The power of x is:\n%.0f", power (x,y)); 15 | 16 | return 0; 17 | } 18 | 19 | double power(int x, int y) 20 | { 21 | int result=1; 22 | int i; 23 | for (i =1; i<=y; i++) 24 | result = result * x; 25 | return result; 26 | } 27 | -------------------------------------------------------------------------------- /1411131007/week7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unsigned long long int fibonacci(unsigned int n); 4 | 5 | int main(void) 6 | { 7 | unsigned int number; 8 | 9 | printf("%s","Enter an integer:"); 10 | scanf("%u",&number); 11 | 12 | unsigned long long result = fibonacci(number); 13 | 14 | printf("fibonacci(%u)=%u",number,result); 15 | } 16 | 17 | unsigned long long int fibonacci(unsigned int n) 18 | { 19 | if(0==n||1==n) { 20 | return n; 21 | } 22 | else{ 23 | return fibonacci(n-1)+fibonacci(n-2); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /1411131059/Array: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 5 3 | 4 | void modifyArray(int b[], int size); 5 | 6 | int main(void) 7 | { 8 | int n[SIZE] = { 19,3,15,7,11 }; 9 | 10 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 11 | 12 | modifyArray(n, SIZE); 13 | } 14 | 15 | void modifyArray(int b[], int size) 16 | { 17 | for (int i = 0; i < size; i++) 18 | { 19 | printf("%7u%13d ", i, b[i]); 20 | 21 | for (int j = 1; j <= b[i]; j++) 22 | { 23 | printf("%c",'*'); 24 | } 25 | puts(""); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /1411131019/1228-2: -------------------------------------------------------------------------------- 1 | // ConsoleApplication2.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。 2 | //給定兩個字串s1、s2,找出s2在s1出現的次數並印出(請使用strncmp、strstr函數) 3 | //s1=abcdefababcdefgh; s2=de 4 | 5 | #include 6 | 7 | int main() 8 | { 9 | int i = 0,a=0; 10 | char s1[14] = "ABcdEfABCcdeF"; 11 | char s2[3] = "cd"; 12 | for (i = 0; i < 13; i++) { 13 | if(strncmp(s2,s1+i,2)==0) //比較s2和s1+i的連續2個字元是否相等 14 | a+=1; //若相等則a+1 15 | } 16 | printf("s1:ABcdEfABCdeF\n"); 17 | printf("s2:cd\n"); 18 | printf("s2在s1出現%d次", a); 19 | } 20 | -------------------------------------------------------------------------------- /1411131001/week16 Q3: -------------------------------------------------------------------------------- 1 | /*題目三 2 | 寫一個程式,能將字串中一個或多個浮點數取出,並且分別印出。Hint: strtod()、strncat() 3 | 範例: 4 | s1 = “abc2.34ababc3.8gh4.4xyz” 5 | 6 | 印出2.34 7 | 3.8 8 | 4.4*/ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | int main(void) { 15 | 16 | char s1[] = "abc2.34ababc3.8gh4.4xyz"; 17 | char* s1Ptr = &s1[0]; 18 | while (*s1Ptr != '\0') { 19 | if (!isdigit(*s1Ptr)) { 20 | s1Ptr++; 21 | } 22 | else { 23 | double d = strtod(s1Ptr, &s1Ptr); 24 | printf("%.2f\n", d); 25 | } 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /1411131035/week7階層: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | unsigned long long int FF(unsigned int n); 5 | int main() 6 | { 7 | int n; 8 | scanf_s("%u", &n); 9 | //const char X = FF(n); 10 | //unsigned long long int XX = FF(n); 11 | 12 | 13 | for (unsigned int i = 0; i <= n; ++i) 14 | { 15 | printf("%u!=%llu\n",i, FF(i)); 16 | } 17 | 18 | } 19 | 20 | unsigned long long int FF(unsigned int n) 21 | { 22 | if (n <= 1) 23 | { 24 | return 1; 25 | } 26 | else 27 | { 28 | return(n * FF(n-1)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /1411031035/week 16: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(){ 6 | char a1[] = "asdf456GHk"; 7 | int i = 0,cnta = 0,cntA = 0,cnt1 = 0; 8 | printf("before:%s\n",a1); 9 | while(a1[i]!='\0'){ 10 | if(islower(a1[i])){ 11 | cnta++; 12 | a1[i]=toupper(a1[i]); 13 | } 14 | else if(isupper(a1[i])){ 15 | cntA++; 16 | a1[i]=tolower(a1[i]); 17 | } 18 | if(isdigit(a1[i])) 19 | cnt1++; 20 | i++; 21 | } 22 | printf("after:%s\n",a1); 23 | printf("upper:%d lower:%d number:%d",cnta,cntA,cnt1); 24 | } 25 | -------------------------------------------------------------------------------- /1411131007/week16-3: -------------------------------------------------------------------------------- 1 | 題目三 2 | 寫一個程式,能將字串中一個或多個浮點數取出,並且分別印出。Hint: strtod()、strncat() 3 | 範例: 4 | s1 = “abc2.34ababc3.8gh4.4xyz” 5 | 印出 6 | 2.34、3.8、4.4\ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | int main (void){ 13 | int cnt = 0, i; 14 | 15 | char s1[] = "abc2.34ababc3.8gh4.4xyz"; 16 | char* s1Ptr = &s1[0]; 17 | 18 | while (*s1Ptr != '\0'){ 19 | if (!isdigit (*s1Ptr) ) { 20 | s1Ptr++; 21 | } 22 | else { 23 | double d = strtod (s1Ptr , &s1Ptr); 24 | printf ("%.2f\n" , d); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /1411131009/1116: -------------------------------------------------------------------------------- 1 | void a(int n[], int star); 2 | int main(void) 3 | 4 | 5 | { 6 | int n[SIZE] = { 19, 3, 15, 7, 11 }, i, j; 7 | 8 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 9 | 10 | 11 | for (i = 0; i < SIZE; ++i) { 12 | printf("%7u%13d ", i, n[i]); 13 | 14 | for (j = 1; j <= n[i]; ++j) { 15 | printf("%c", '*'); 16 | } 17 | 18 | puts(""); 19 | } 20 | 21 | void a(int n[], int star); 22 | 23 | for (j = 1; j <= n[i]; ++j) { 24 | printf("%c", '*'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /1411131017/week6 P.250延伸練習: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | unsigned int i; 8 | unsigned int n, m, temp; 9 | 10 | printf("Enter n<5 : "); 11 | scanf_s("%u",&n); 12 | 13 | srand(n); 14 | 15 | for (i = 1; i <= pow(10, n); ++i) { 16 | temp = pow(10, n); 17 | m = rand() % temp; 18 | 19 | printf("%10lf", (double)m / pow(10, n)); 20 | 21 | if (i % 5 == 0) { 22 | puts(""); 23 | } 24 | } 25 | 26 | 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /1411131047/2022-10-5-2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | double principal, rate; 7 | int year; 8 | 9 | printf_s("principal is "); 10 | scanf_s("%lf", &principal); 11 | 12 | printf_s("rate is "); 13 | scanf_s("%lf", &rate); 14 | rate += 1; 15 | 16 | printf_s("year"); 17 | scanf_s("%d", &year); 18 | 19 | 20 | for (unsigned int i=1 ; i<=year ; ++i) { 21 | 22 | principal *= rate; 23 | printf_s("%d Year %.2f\n", i, principal); 24 | } 25 | } -------------------------------------------------------------------------------- /1411131047/22-11-16-p2-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define RESPONSES_SIZE 40 3 | #define FREQUENCY_SIZE 11 4 | 5 | 6 | int main() { 7 | int ar[RESPONSES_SIZE] = { 1, 2, 6, 4, 8, 5, 9, 7, 8, 10,1, 6, 3, 8, 6, 10, 3, 8, 2, 7, 6, 5, 7, 6, 8, 6, 7, 5, 6, 6,5, 6, 7, 5, 6, 4, 8, 6, 8, 10 }, rat[FREQUENCY_SIZE] = {0}, i; 8 | printf_s("%s%17s\n", "Rating", "Frequency"); 9 | 10 | for (i = 0; i < RESPONSES_SIZE; i++) { 11 | rat[ar[i]] += 1; 12 | } 13 | 14 | for (i = 1; i < FREQUENCY_SIZE; i++) { 15 | printf_s("%6d%17d\n", i, rat[i]); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /1411131039/1116Q1: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 5 3 | 4 | void a(int x[],int size); 5 | int main(void) 6 | { 7 | int n[SIZE] = {19, 3, 15, 7, 11},i,j; 8 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 9 | 10 | 11 | for (i = 0; i < SIZE; ++i) { 12 | printf("%7u%13d ", i, n[i]) ; 13 | a(n,i); 14 | puts(""); 15 | } 16 | } 17 | void a(int x[],int size){ 18 | int j; 19 | for ( j = 0; j < x[size]; ++j) { 20 | printf("%c", '*'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /1411131007/week10-1: -------------------------------------------------------------------------------- 1 | //題目1: 修改課本306、307頁的程式fig06_06.c,印出柱狀圖的程式碼放入一個副程式中,並透過陣列傳遞的方式,將兩個陣列與size傳送到副程式中印出。 2 | 3 | #include 4 | #define SIZE 5 5 | 6 | void sub1(int n[],size_t size); 7 | 8 | int main(void) 9 | { 10 | int n[SIZE] = {19,3,15,7,11},i; 11 | 12 | printf("%s%13s%17s\n","Element","Value","Histogram"); 13 | 14 | for (i=0;i 2 | #include 3 | 4 | int main(void) 5 | { 6 | double principal = 0; 7 | double rate = 0; 8 | //double year = 0; 9 | int a = 0; 10 | 11 | printf("輸入第一年本金:"); 12 | scanf_s("%lf", &principal); 13 | printf("輸入定存利率:"); 14 | scanf_s("%lf", &rate); 15 | printf("輸入定存多久:"); 16 | scanf_s("%d", &a); 17 | 18 | for (unsigned int year = 1; year<=a;++year) 19 | { 20 | 21 | double amount = principal * pow(1.0 + rate, year); 22 | printf("%4u%21.2f\n", year, amount); 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /1411131039/1228Q1: -------------------------------------------------------------------------------- 1 | //計算字串英文大小寫、數字的數量,並將英文大小寫轉換相反 2 | #include 3 | #include 4 | #include 5 | int main() { 6 | char s1[]="aBc4DE6fz"; 7 | char s2[]="aBc4DE6fz"; 8 | int i=0,cnta=0,cntA=0,cnt1=0; 9 | printf("原始字串:%s\n",s1); 10 | while(s1[i]!='\0'){ 11 | if(islower(s1[i])){ 12 | cnta++; 13 | s2[i]=toupper(s1[i]); 14 | } 15 | if(isupper(s1[i])){ 16 | cntA++; 17 | s2[i]=tolower(s1[i]); 18 | } 19 | if(isdigit(s1[i])) 20 | cnt1++; 21 | i++; 22 | } 23 | printf("轉換後字串:%s\n",s2); 24 | printf("大寫:%d 小寫:%d 數字:%d",cntA,cnta,cnt1); 25 | } 26 | -------------------------------------------------------------------------------- /1411131039/1005Q2: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) 4 | { 5 | double principal; 6 | double rate; 7 | int period; 8 | printf("請輸入第一年本金:"); 9 | scanf("%lf",&principal); 10 | printf("\n請輸入定存利率(%%):"); 11 | scanf("%lf",&rate); 12 | printf("\n請輸入定存年數(年):"); 13 | scanf("%d",&period); 14 | int year; 15 | printf("%4s%21s\n", "Year", "Amount on deposit"); 16 | for (year = 1;year<=period;++year) 17 | { 18 | double amount = principal * pow(1.0 + rate, year); 19 | 20 | printf("%4u%21.2f\n", year, amount); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /1411131007/week2-1: -------------------------------------------------------------------------------- 1 | int integer1; 2 | int integer2; 3 | 4 | printf( "Enter first integer\n" ); 5 | scanf( "%d", &integer1 ); 6 | 7 | printf( "Enter second integer\n" ); 8 | scanf( "%d", &integer2 ); 9 | 10 | int sum; 11 | sum = integer1 + integer2; 12 | printf( "Sum is %d\n", sum ); 13 | sum = integer1 - integer2; 14 | printf( "Sum is %d\n", sum ); 15 | sum = integer1 * integer2; 16 | printf( "Sum is %d\n", sum ); 17 | sum = integer1 / integer2; 18 | printf( "Sum is %d\n", sum ); 19 | sum = integer1 % integer2; 20 | printf( "Sum is %d\n", sum ); 21 | -------------------------------------------------------------------------------- /1411131021/W5-1: -------------------------------------------------------------------------------- 1 | // Creating and using a programmer-defined function. 2 | #include 3 | 4 | int square(int); // function prototype 原型宣告 5 | 6 | int main(void) 7 | {int x; 8 | // loop 10 times and calculate and output square of x each time 9 | for (x = 1; x <= 10; ++x) { 10 | printf("%d ", square(x)); // function call 11 | } 12 | 13 | puts(""); 14 | } 15 | 16 | // square function definition returns the square of its parameter 17 | int square(int y) // y is a copy of the argument to the function 18 | { 19 | return y * y; // returns the square of y as an int 20 | } 21 | -------------------------------------------------------------------------------- /1411131011/week5 5.5: -------------------------------------------------------------------------------- 1 | // Creating and using a programmer-defined function. 2 | #include 3 | 4 | int square(int); // function prototype 原型宣告 5 | 6 | int main(void) 7 | { 8 | int x; 9 | // loop 10 times and calculate and output square of x each time 10 | for (x = 2; x <= 11; ++x) { 11 | printf("%d ", square(x)); // function call 12 | } 13 | 14 | puts(""); 15 | } 16 | 17 | // square function definition returns the square of its parameter 18 | int square(int y) // y is a copy of the argument to the function 19 | { 20 | return y + y; // returns the square of y as an int 21 | } 22 | -------------------------------------------------------------------------------- /1411131047/22-10-19.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | unsigned int i, temp, n,ed; 7 | double asw,st; 8 | 9 | printf_s("Enter n: "); 10 | scanf_s("%d", &n); 11 | n = pow(10, n); 12 | ed = n - 1; 13 | st = (double)1 / n; 14 | //printf_s("%lf\n", st); 15 | 16 | for (i = 1; i <= n; ++i) { 17 | temp = rand() % ed; 18 | asw = (double)temp / n + st; 19 | printf_s("%lf ", asw); 20 | if (i % 5 == 0) { 21 | printf_s("\n"); 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /1411131059/2.17: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int u; 6 | int a; 7 | int t; 8 | 9 | printf("Enter initial velocity\n"); 10 | scanf_s("%d", &u); 11 | 12 | printf("Enter acceleration\n"); 13 | scanf_s("%d", &a); 14 | 15 | printf("Enter the time\n"); 16 | scanf_s("%d", &t); 17 | 18 | int finalvelocity; 19 | finalvelocity = u + a * t; 20 | 21 | int distancetraversed; 22 | distancetraversed = u * t + (a * (t * t)) / 2; 23 | 24 | printf("final velocity is %d\n", finalvelocity); 25 | printf("distance traversed is %d\n", distancetraversed); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /week/week5/basic function call: -------------------------------------------------------------------------------- 1 | // Creating and using a programmer-defined function. 2 | #include 3 | 4 | int square(int); // function prototype 原型宣告 5 | 6 | int main(void) 7 | {int x; 8 | // loop 10 times and calculate and output square of x each time 9 | for (x = 1; x <= 10; ++x) { 10 | printf("%d ", square(x)); // function call 11 | } 12 | 13 | puts(""); 14 | } 15 | 16 | // square function definition returns the square of its parameter 17 | int square(int y) // y is a copy of the argument to the function 18 | { 19 | return y * y; // returns the square of y as an int 20 | } 21 | -------------------------------------------------------------------------------- /1411131049/w16 q1: -------------------------------------------------------------------------------- 1 | //給定一個字串,先計算且印出字串中的大、小寫與數字的數量,之後將字串中的大、小寫互換之後,再將互換後的字串印出。 2 | #include 3 | #include 4 | #include 5 | 6 | int main(){ 7 | char a1[] = "asdf456GHk"; 8 | int i = 0,cnta = 0,cntA = 0,cnt1 = 0; 9 | printf("before:%s\n",a1); 10 | while(a1[i]!='\0'){ 11 | if(islower(a1[i])){ 12 | cnta++; 13 | a1[i]=toupper(a1[i]); 14 | } 15 | else if(isupper(a1[i])){ 16 | cntA++; 17 | a1[i]=tolower(a1[i]); 18 | } 19 | if(isdigit(a1[i])) 20 | cnt1++; 21 | i++; 22 | } 23 | printf("after:%s\n",a1); 24 | printf("upper:%d lower:%d number:%d",cnta,cntA,cnt1); 25 | } 26 | -------------------------------------------------------------------------------- /1411131049/w10 01: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 5 3 | 4 | void modifyArray(int b[],int size); 5 | 6 | int main(void){ 7 | int n[SIZE] = {19, 3, 15, 7, 11},i,j; 8 | 9 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 10 | 11 | modifyArray(n,SIZE); 12 | } 13 | void modifyArray(int b[],int size) 14 | { 15 | 16 | for (int i = 0; i < SIZE; ++i) { 17 | printf("%7u%13d ", i, b[i]) ; 18 | 19 | for (int j = 1; j <= b[i]; ++j) { 20 | printf("%c", '*'); 21 | } 22 | 23 | puts(""); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /1411131041/week7-test: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int f(int n); 5 | 6 | int main(void) 7 | { 8 | int n; 9 | int i; 10 | int a = 0; 11 | int b = 1; 12 | int c = 0; 13 | scanf_s("%d", &n); 14 | printf("%d\n",f(n)); 15 | 16 | if (n<=1) 17 | { 18 | printf("%d\n", f(n)); 19 | } 20 | else 21 | { 22 | for (i = 1; i < n; i++) 23 | { 24 | c = a + b; 25 | a = b; 26 | b = c; 27 | 28 | } 29 | printf("%d\n", c); 30 | } 31 | 32 | } 33 | 34 | int f(int n) 35 | { 36 | 37 | if (n <= 1) 38 | { 39 | return n; 40 | } 41 | else { 42 | return f(n - 1) + f(n - 2); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /1411131033/week4: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) { 5 | 6 | double principal = 0; 7 | double rate = 0; 8 | int year = 0; 9 | int x = 0; 10 | printf("輸入第一年本金:"); 11 | scanf_s("%lf", &principal); 12 | printf("輸入利率:"); 13 | scanf_s("%lf", &rate); 14 | printf("定存年限:"); 15 | scanf_s("%d", &x); 16 | 17 | 18 | for (unsigned int year = 1; year <= x; ++year) { 19 | 20 | double amount = principal * pow(1.0 + rate, year); 21 | 22 | printf("本利和=%4u%21.2f\n", year, amount); 23 | if (year > x-1) { 24 | break; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /1411031035/week 4: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) { 5 | 6 | double principal = 0; 7 | double rate = 0; 8 | int year = 0; 9 | int x = 0; 10 | printf("輸入第一年本金:"); 11 | scanf_s("%lf", &principal); 12 | printf("輸入利率:"); 13 | scanf_s("%lf", &rate); 14 | printf("定存年限:"); 15 | scanf_s("%d", &x); 16 | 17 | 18 | for (unsigned int year = 1; year <= x; ++year) { 19 | 20 | double amount = principal * pow(1.0 + rate, year); 21 | 22 | printf("本利和=%4u%21.2f\n", year, amount); 23 | if (year > x-1) { 24 | break; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /1411131047/2022-10-5-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int pas = 0, fal = 0, stu = 0, res,bp; 5 | 6 | printf_s("Enter Result (1=pass, 2=fail, -1=abort): "); 7 | scanf_s("%d", &res); 8 | 9 | while (res != -1) { 10 | if (res == 1) pas++; 11 | 12 | if (res == 2) fal++; 13 | 14 | stu++; 15 | printf_s("Enter Result (1=pass, 2=fail, -1=abort): "); 16 | scanf_s("%d", &res); 17 | } 18 | 19 | printf_s("Passed %d\n", pas); 20 | printf_s("Failed %d\n", fal); 21 | printf_s("%.1f",(float)pas/stu*100); 22 | printf_s("%%\n"); 23 | 24 | 25 | if ((float)pas / stu >= 0.8) printf_s("Bouns to instructor"); 26 | } -------------------------------------------------------------------------------- /1411131007/week4-2: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | double principal = 5000.0; 7 | double rate = 0.02; 8 | int period; 9 | 10 | printf("輸入第一年本金:"); 11 | scanf("%lf", &principal); 12 | 13 | printf("輸入定存利率(%%):"); 14 | scanf("%lf", &rate); 15 | 16 | printf("輸入定存時間(年):"); 17 | scanf("%d", &period); 18 | 19 | 20 | printf("\nYear Amount on deposit\n"); 21 | 22 | for (unsigned int year = 1 ; year <= period ; ++year) { 23 | 24 | double amount = principal * pow(1.0 + rate, year); 25 | 26 | printf("%4u%21.2f\n", year, amount); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /1411131049/W4: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | double principal; 8 | printf("輸入第一年本金:"); 9 | scanf("%lf",&principal); 10 | double rate; 11 | printf("輸入定存利率(%%):"); 12 | scanf("%lf",&rate); 13 | int period; 14 | printf("輸入定存多久(年):"); 15 | scanf("%d",&period); 16 | 17 | printf("%4s%21s\n", "Year", "Amount on deposit"); 18 | 19 | 20 | for (unsigned int year = 1; year <= period; ++year) { 21 | 22 | 23 | double amount = principal * pow(1.0 + rate,year); 24 | 25 | 26 | printf("%4u%21.2f\n", year, amount); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /1411131051/利率: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | double principal = 1000.0; 7 | double rate = .05; 8 | double period= 0; 9 | printf("輸入第一年本金:"); 10 | scanf_s("%lf", &principal); 11 | printf("輸入利率:"); 12 | scanf_s("%lf", &rate); 13 | printf("輸入定存時間(年):"); 14 | scanf_s("%lf", &period); 15 | 16 | printf("%4s%21s\n", "Year", "Amount on deposit"); 17 | 18 | 19 | for (unsigned int year = 1; year <= period; ++year) { 20 | 21 | 22 | double amount = principal * pow(1.0 + rate, year); 23 | 24 | 25 | printf("%4u%21.2f\n", year, amount); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /1411131029/week1 (2.16): -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int integer1; 6 | int integer2; 7 | 8 | printf("Enter first integer\n"); 9 | scanf_s("%d", &integer1); 10 | 11 | printf("Enter second integer\n"); 12 | scanf_s("%d", &integer2); 13 | 14 | int sum; 15 | sum = integer1 + integer2; 16 | printf("sum is % d\n", sum); 17 | sum = integer1 - integer2; 18 | printf("sum is % d\n", sum); 19 | sum = integer1 * integer2; 20 | printf("sum is % d\n", sum); 21 | sum = integer1 / integer2; 22 | printf("sum is % d\n", sum); 23 | sum = integer1 % integer2; 24 | printf("sum is % d\n", sum); 25 | } 26 | -------------------------------------------------------------------------------- /1411131023/week10 P1: -------------------------------------------------------------------------------- 1 | 題目:修改課本306、307頁的程式fig06_06.c,印出柱狀圖的程式碼放入一個副程式中,並透過陣列傳遞的方式,將兩個陣列與size傳送到副程式中印出。 2 | #include 3 | #define SIZE 5 4 | 5 | void histograms(int s[], int i, int j); 6 | int main() 7 | { 8 | int j,i=0; 9 | int s[SIZE]; 10 | for (j = 0; j < SIZE; j++) { 11 | s[j] = 2 + 2 * j; 12 | } 13 | printf("%s%13s%17s\n", "Element", "Value","Histograms"); 14 | 15 | histograms(s, i, j); 16 | } 17 | void histograms(int s[], int i, int j) { 18 | 19 | for (i = 0; i < SIZE; i++) { 20 | printf("%7u%13d ", i, s[i]); 21 | 22 | 23 | for (j = 0; j < s[i]; j++) { 24 | printf("%c", '*'); 25 | 26 | } 27 | puts(""); 28 | } 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /1411131021/W5-3: -------------------------------------------------------------------------------- 1 | // Fig. 5.3: fig05_03.c 2 | // Creating and using a programmer-defined function. 3 | #include 4 | 5 | int facto(int); // function prototype 原型宣告 6 | 7 | int main(void) 8 | {int x; 9 | // loop 10 times and calculate and output square of x each time 10 | for (x = 1; x <= 15; ++x) { 11 | printf("%d ", facto(x)); // function call 12 | } 13 | 14 | puts(""); 15 | } 16 | 17 | // square function definition returns the square of its parameter 18 | int facto(int y) // y is a copy of the argument to the function 19 | {int result=1,i; 20 | for(i=1;i<=y;i++) 21 | result=result*i; 22 | return result; // returns the square of y as an int 23 | } 24 | -------------------------------------------------------------------------------- /1411131035/week2運算符號測試: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int number1; 6 | int number2; 7 | 8 | 9 | printf("Enter first number\n"); 10 | scanf_s("%d", &number1); 11 | 12 | printf("Enter second number\n"); 13 | scanf_s("%d", &number2); 14 | 15 | int sum = number1 + number2; 16 | printf("\nSum is %d\n", sum); 17 | int average = number1 - number2; 18 | printf("Average is %d\n", average); 19 | int product = number1 * number2; 20 | printf("Product is %d\n", product); 21 | int div = number1 / number2; 22 | printf("Div is %d\n", div); 23 | int mod = number1 % number2; 24 | printf("Mod is %d\n", mod); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /1411131047/0928-2.19.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a, b, c,asw,sm,la ; 5 | 6 | printf_s("Enter three different inttegers: "); 7 | scanf_s(" %d %d %d", &a, &b, &c); 8 | 9 | asw = a + b + c; 10 | printf_s("Sum is %d\n", asw); 11 | 12 | asw =asw/3 ; 13 | printf_s("Average is %d\n", asw); 14 | 15 | asw = a * b * c; 16 | printf_s("Product is %d\n", asw); 17 | 18 | sm = a; 19 | la = b; 20 | if (b < a) { 21 | sm = b; 22 | la = a; 23 | } 24 | if (c < sm) { 25 | sm = c; 26 | } 27 | if (c > la) { 28 | la = c; 29 | } 30 | printf_s("Smallest is %d\n", sm); 31 | printf_s("Largest is %d\n", la); 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /1411131059/字串: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | int i = 0; 7 | int cnta = 0; 8 | int cntA = 0; 9 | int cnt1 = 0; 10 | char s1[] = "abcDEF6"; 11 | char s2[] = "abcDEF6"; 12 | 13 | while (s2[i] != '\0') 14 | { 15 | if (islower(s2[i])) 16 | { 17 | cnta += 1; 18 | s1[i] = toupper(s2[i]); 19 | } 20 | if (isupper(s2[i])) 21 | { 22 | cntA += 1; 23 | s1[i] = tolower(s2[i]); 24 | } 25 | if (isdigit(s2[i])) 26 | { 27 | cnt1 += 1; 28 | s1[i] = s2[i]; 29 | } 30 | i++; 31 | } 32 | printf("Digit: %d\nLowercase: %d\nUppercase: %d\n", cnt1, cnta, cntA); 33 | printf("Original %s turn to %s", s2, s1); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /week/week5/Factorial function: -------------------------------------------------------------------------------- 1 | // Fig. 5.3: fig05_03.c 2 | // Creating and using a programmer-defined function. 3 | #include 4 | 5 | int facto(int); // function prototype 原型宣告 6 | 7 | int main(void) 8 | {int x; 9 | // loop 10 times and calculate and output square of x each time 10 | for (x = 1; x <= 15; ++x) { 11 | printf("%d ", facto(x)); // function call 12 | } 13 | 14 | puts(""); 15 | } 16 | 17 | // square function definition returns the square of its parameter 18 | int facto(int y) // y is a copy of the argument to the function 19 | {int result=1,i; 20 | for(i=1;i<=y;i++) 21 | result=result*i; 22 | return result; // returns the square of y as an int 23 | } 24 | -------------------------------------------------------------------------------- /1411131011/week 6: -------------------------------------------------------------------------------- 1 | int main(void) 2 | { 3 | unsigned int i; 4 | unsigned int n,m,temp; // number used to seed the random number generator 5 | 6 | printf("%s", "Enter n,n<5: "); 7 | scanf_s("%u", &n); // note %u for unsigned int 8 | 9 | srand(n); // seed the random number generator 10 | 11 | // loop 10 times 12 | for (i = 1; i <= 10; ++i) { 13 | temp = pow(10, n); 14 | m = rand() % temp; 15 | // pick a random number from 1 to 6 and output it 16 | printf("%10lf", (double)m/pow(10,n)); 17 | 18 | // if counter is divisible by 5, begin a new line of output 19 | if (i % 5 == 0) { 20 | puts(""); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /week/week2/Fig.02_05: -------------------------------------------------------------------------------- 1 | // Fig. 2.5: fig02_05.c 2 | // Addition program 3 | #include 4 | 5 | // function main begins program execution 6 | int main( void ) 7 | { 8 | int integer1; // first number to be entered by user 9 | int integer2; // second number to be entered by user 10 | 11 | printf( "Enter first integer\n" ); // prompt 12 | scanf( "%d", &integer1 ); // read an integer 13 | 14 | printf( "Enter second integer\n" ); // prompt 15 | scanf( "%d", &integer2 ); // read an integer 16 | 17 | int sum; // variable in which sum will be stored 18 | sum = integer1 + integer2; // assign total to sum 19 | 20 | printf( "Sum is %d\n", sum ); // print sum 21 | } // end function main 22 | -------------------------------------------------------------------------------- /1411131011/week 10-1: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 5 3 | 4 | void modifyArray(int b[], size_t size); 5 | 6 | int main(void) 7 | { 8 | // use initializer list to initialize array n 9 | int n[SIZE] = { 19, 3, 15, 7, 11 }, i, j; 10 | 11 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 12 | 13 | // for each element of array n , output a bar of the histogram 14 | for (i = 0; i < SIZE; ++i) { 15 | printf("%7u%13d ", i, n[i]); 16 | 17 | modifyArray(n, n[i]); 18 | 19 | } 20 | } 21 | 22 | void modifyArray(int b[], size_t size) 23 | { 24 | for (size_t j = 1; j <= size_t size;++j){//printf one bar 25 | printf("%c". '*'); 26 | } 27 | puts(""); // end a bar with a newline 28 | 29 | } 30 | -------------------------------------------------------------------------------- /1411131007/week11 (原始程式): -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 10 3 | 4 | int main(void) 5 | { 6 | int a[SIZE] = { 2, 6, 4, 8, 10, 12, 89, 68, 45, 37}; 7 | int i; 8 | 9 | puts ("Date items in original order"); 10 | 11 | for (i=0; i < SIZE; ++i){ 12 | printf ("%4d", a[i]); 13 | } 14 | 15 | 16 | for (unsigned int pass=1; pass < SIZE; ++pass){ 17 | 18 | for (i=0; i < SIZE; ++i){ 19 | 20 | if (a[i] > a[i + 1]){ 21 | int hold = a[i]; 22 | a[i] = a[i + 1]; 23 | a[i + 1] =hold; 24 | } 25 | 26 | } 27 | 28 | } 29 | 30 | puts ("\nDate items in original order"); 31 | 32 | for (i=0; i < SIZE; ++i){ 33 | printf ("%4d", a[i]); 34 | } 35 | 36 | puts (" "); 37 | } 38 | -------------------------------------------------------------------------------- /1411131021/1228-W16-2: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | 7 | 8 | char s1[] = "Hdd4h Trh2b5"; 9 | char s2[] = "Hdd4h Trh2b5"; 10 | int i = 0; 11 | int cnta = 0; 12 | int cntA = 0; 13 | int cnt1 = 0; 14 | int retum = 0; 15 | 16 | while(s2[i]!='\0') { 17 | if(islower(s2[i])) { 18 | cnta += 1; 19 | s1[i] = toupper(s2[i]); 20 | } 21 | 22 | if(isupper(s2[i])) { 23 | cntA += 1; 24 | s1[i] = tolower(s2[i]); 25 | } 26 | 27 | if (isdigit(s2[i])) { 28 | cnt1 += 1; 29 | s1[i] = s2[i]; 30 | } 31 | 32 | 33 | i++; 34 | } 35 | printf("%d個小寫\n", cnta); 36 | printf("%d個大寫\n", cntA); 37 | printf("%d個數\n",cnt1); 38 | printf("%s\n", s1); 39 | } 40 | -------------------------------------------------------------------------------- /1411131035/week10_修改306、307頁的程式fig06_06.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 5 3 | 4 | void ZXC(int n[], rsize_t se); 5 | 6 | int main(void) 7 | { 8 | // use initializer list to initialize array n 9 | int a[SIZE] = { 19, 3, 15, 7, 11 }, i, j; 10 | 11 | ZXC(a,SIZE); 12 | 13 | 14 | } 15 | 16 | void ZXC(int n[],rsize_t se) 17 | { 18 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 19 | for (rsize_t i = 0; i < se; ++i) 20 | { 21 | printf("%7u%13d ", i, n[i]); 22 | 23 | for (rsize_t j = 1; j <= n[i]; ++j) { // print one bar 24 | printf("%c", '*'); 25 | } 26 | puts(""); // end a histogram bar with a newline 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /1411131039/1005Q1: -------------------------------------------------------------------------------- 1 | int main() { 2 | unsigned int passes = 0; 3 | unsigned int failures = 0; 4 | unsigned int student = 0; 5 | int result=0; 6 | while (result!=-1) { 7 | printf("Enter result ( 1=pass,2=fail,-1=abord ): " ); 8 | scanf( "%d", &result ); 9 | if ( result == 1 ){ 10 | passes++; 11 | student++; 12 | } 13 | else if(result==2){ 14 | failures++; 15 | student++; 16 | } 17 | } 18 | printf( "Passed %u\n", passes ); 19 | printf( "Failed %u\n", failures ); 20 | float n; 21 | n=(float)passes/student; 22 | printf("通過率:%.2f \n",n); 23 | if ( n>= 0.8 ) 24 | puts( "Bonus to instructor!" ); 25 | } 26 | -------------------------------------------------------------------------------- /week/week4/p193practice(bouns): -------------------------------------------------------------------------------- 1 | // Fig. 4.6: fig04_06.c 2 | // Calculating compound interest 3 | #include 4 | #include 5 | 6 | int main(void) 7 | { 8 | double principal = 1000.0; // starting principal 9 | double rate = .05; // annual interest rate 10 | 11 | // output table column heads 12 | printf("%4s%21s\n", "Year", "Amount on deposit"); 13 | 14 | // calculate amount on deposit for each of ten years 15 | for (unsigned int year = 1; year <= 10; ++year) { 16 | 17 | // calculate new amount for specified year 18 | double amount = principal * pow(1.0 + rate, year); 19 | 20 | // output one table row 21 | printf("%4u%21.2f\n", year, amount); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /1411131039/20220928: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) 4 | { 5 | printf("Enter a grade,and I will tell you\n"); 6 | printf("the results:"); 7 | int num1; 8 | scanf_s("%d", &num1); 9 | if (num1 >= 90) { 10 | puts("A"); 11 | } 12 | else { 13 | if(num1 >= 80) { 14 | puts("B"); 15 | } 16 | else { 17 | if (num1 >= 70) { 18 | puts("C"); 19 | } 20 | else { 21 | if (num1 >= 60) { 22 | puts("D"); 23 | } 24 | else { 25 | puts("F"); 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /1411131055/1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int integer1; 6 | int integer2; 7 | 8 | printf("Enter first integer\n"); 9 | scanf_s("%d", &integer1); 10 | printf("Enter second integer\n"); 11 | scanf_s("%d", &integer2); 12 | 13 | int A; 14 | int B; 15 | int C; 16 | int D; 17 | int E; 18 | 19 | A= integer1 + integer2; 20 | printf("Sum is %d\n", A); 21 | B = integer1 - integer2; 22 | printf("dif is %d\n", B); 23 | C = integer1 * integer2; 24 | printf("take is %d\n", C); 25 | D = integer1 / integer2; 26 | printf("dif is %d\n", D); 27 | E = integer1 % integer2; 28 | printf("mod is %d\n", E); 29 | 30 | int sum; 31 | sum = integer1 + integer2; 32 | printf("Sum is %d\n", sum); 33 | } 34 | -------------------------------------------------------------------------------- /1410931042/w7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main(void) 5 | { 6 | int x = 0, y = 0; 7 | printf("輸入一整數"); 8 | scanf_s("%d", &x); 9 | int fib[100]; 10 | int n, i; 11 | fib[1] = 1; 12 | fib[2] = 1; 13 | for (i = 3; i <= x; i++) 14 | fib[i] = fib[i - 1] + fib[i - 2]; 15 | 16 | printf("輸入數值之費波納切係數為%d", fib[x]); 17 | } 18 | 19 | #include 20 | 21 | int f(int n) 22 | { 23 | if (n == 1 or n == 2) 24 | return 1; 25 | else 26 | { 27 | return f(n - 1) + f(n - 2); 28 | } 29 | 30 | } 31 | int main(void) 32 | { 33 | int x=0,y=0; 34 | printf("輸入一整數"); 35 | scanf_s("%d", &x); 36 | y = f(x); 37 | printf("輸入數值之費波納切係數為%d", y); 38 | } 39 | -------------------------------------------------------------------------------- /phillip0085/1012 ps1 設計階乘分母函數: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double expo(int); // function prototype 原型宣告 4 | 5 | int main(void) 6 | { 7 | int x; 8 | // loop 10 times and calculate and output square of x each time 9 | for (x = 1; x <= 10; ++x) { 10 | printf("The value of e is: %lf\n", expo(x)); // function call 11 | } 12 | 13 | puts(""); 14 | } 15 | 16 | // square function definition returns the square of its parameter 17 | double expo (int y) // y is a copy of the argument to the function 18 | { 19 | int result = 1, i; 20 | double expo = 1; 21 | for (i = 1; i <= y; i++) { 22 | result = result * i; 23 | expo = expo + (1.0 / result); 24 | } 25 | 26 | return expo; // returns the square of y as an int 27 | } 28 | -------------------------------------------------------------------------------- /1411131003/week5 (1): -------------------------------------------------------------------------------- 1 | // Fig. 5.3: fig05_03.c 2 | // Creating and using a programmer-defined function. 3 | #include 4 | 5 | int facto(int); // function prototype 原型宣告 6 | int main(void) 7 | { 8 | int x; 9 | // loop 10 times and calculate and output square of x each time 10 | for (x = 1; x <= 15; ++x) { 11 | printf("%d ", facto(x)); // function call 12 | } 13 | printf("the value of 'e' is:%1f"); 14 | puts(""); 15 | } 16 | 17 | // square function definition returns the square of its parameter 18 | int facto(int y) // y is a copy of the argument to the function 19 | { 20 | int result = 1, i; 21 | for (i = 1; i <= y; i++) 22 | result = result * i; 23 | return result; // returns the square of y as an int 24 | } 25 | -------------------------------------------------------------------------------- /phillip0085/0921HW16: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int integer1, integer2, sum, product, difference, quotient, remainder; 6 | printf("Enter first number:\n"); 7 | scanf_s("%d", &integer1); 8 | 9 | printf("Enter second number:\n"); 10 | scanf_s("%d", &integer2); 11 | 12 | sum = integer1 + integer2; 13 | product = integer1 * integer2; 14 | difference = integer1 - integer2; 15 | quotient = integer1 / integer2; 16 | remainder = integer1 % integer2; 17 | 18 | printf("Sum is %d\n", sum); 19 | printf("Product is %d\n", product); 20 | printf("Difference is %d\n", difference); 21 | printf("Quotient is %d\n", quotient); 22 | printf("Remainder is %d\n", remainder); 23 | } 24 | -------------------------------------------------------------------------------- /1411131033/week10-1: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 5 3 | #include 4 | #include 5 | 6 | void modifyArray(int n[],rsize_t s); 7 | int n[SIZE] = {19, 3, 15, 7, 11},i,j; 8 | 9 | int main(void) 10 | { 11 | 12 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 13 | modifyArray(n,SIZE); 14 | 15 | } 16 | 17 | void modifyArray(int n[],rsize_t s){ 18 | 19 | 20 | 21 | for (i = 0; i < SIZE; ++i) { 22 | printf("%7u%13d ", i, n[i]) ; 23 | 24 | for ( j = 1; j <= n[i]; ++j) { // print one bar 25 | printf("%c", '*'); 26 | } 27 | 28 | puts(""); // end a histogram bar with a newline 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /1411131011/week1 2.16: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int integer1, integer2, sum, subtraction, multiplication, division, remainder; 6 | 7 | printf("Enter first integer\n"); 8 | scanf_s("%d", &integer1); 9 | 10 | printf("Enter second integer\n"); 11 | scanf_s("%d", &integer2); 12 | 13 | sum = integer1 + integer2; 14 | printf("\nSum is %d\n", sum); 15 | 16 | subtraction = integer1 - integer2; 17 | printf("Subtraction is %d\n", subtraction); 18 | 19 | multiplication= integer1 * integer2; 20 | printf("Multiplication is %d\n", multiplication); 21 | 22 | division = integer1 / integer2; 23 | printf("Division is %d\n", division); 24 | 25 | remainder = integer1 % integer2; 26 | printf("Remainder is %d\n", remainder); 27 | } 28 | -------------------------------------------------------------------------------- /1411131021/W6-1: -------------------------------------------------------------------------------- 1 | // Fig. 5.13: fig05_13.c 2 | // Randomizing die-rolling program. 3 | #include 4 | #include 5 | 6 | int main(void) 7 | {unsigned int i; 8 | unsigned int seed; // number used to seed the random number generator 9 | 10 | printf("%s", "Enter seed: "); 11 | scanf("%u", &seed); // note %u for unsigned int 12 | 13 | srand(seed); // seed the random number generator 14 | 15 | // loop 10 times 16 | for (i = 1; i <= 10; ++i) { 17 | 18 | // pick a random number from 1 to 6 and output it 19 | printf("%10d", 1 + (rand() % 6)); 20 | 21 | // if counter is divisible by 5, begin a new line of output 22 | if (i % 5 == 0) { 23 | puts(""); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /1411131045/class-week7.cpp: -------------------------------------------------------------------------------- 1 | // class-week7.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。 2 | // 3 | 4 | #include 5 | int f(int); 6 | int main(void) 7 | { 8 | int n; 9 | scanf_s("%d", &n); 10 | printf("%d\n", f(n)); 11 | } 12 | int f(int n) 13 | { 14 | if (n <= 1) 15 | return n; 16 | else 17 | return f(n-2) + f(n - 1); 18 | } 19 | 20 | 21 | // 執行程式: Ctrl + F5 或 [偵錯] > [啟動但不偵錯] 功能表 22 | // 偵錯程式: F5 或 [偵錯] > [啟動偵錯] 功能表 23 | 24 | // 開始使用的提示: 25 | // 1. 使用 [方案總管] 視窗,新增/管理檔案 26 | // 2. 使用 [Team Explorer] 視窗,連線到原始檔控制 27 | // 3. 使用 [輸出] 視窗,參閱組建輸出與其他訊息 28 | // 4. 使用 [錯誤清單] 視窗,檢視錯誤 29 | // 5. 前往 [專案] > [新增項目],建立新的程式碼檔案,或是前往 [專案] > [新增現有項目],將現有程式碼檔案新增至專案 30 | // 6. 之後要再次開啟此專案時,請前往 [檔案] > [開啟] > [專案],然後選取 .sln 檔案 31 | -------------------------------------------------------------------------------- /phillip0085/0928pset1 分數pass or fail: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int a; 6 | 7 | printf("Please enter your score:\n"); 8 | scanf_s ("%d", &a); 9 | 10 | if (a >= 90) { 11 | puts("Result: A"); 12 | } 13 | else { 14 | if (a >= 80) { 15 | puts("Result: B"); 16 | } 17 | else{ 18 | if (a >= 70) { 19 | puts("Result: C"); 20 | } 21 | else { 22 | if (a >= 60) { 23 | puts("Result: D"); 24 | } 25 | else { 26 | puts("Result: F"); 27 | 28 | } 29 | } 30 | } 31 | } 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /1411131023/week16 P1: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | char s1[] = "abcDEF3"; 6 | char s2[] = "abcDEF3"; 7 | 8 | int i = 0, cnta = 0, cntA = 0, cnt1 = 0; 9 | 10 | while (s2[i] != '\0') { 11 | if (islower(s2[i])) { 12 | cnta += 1; 13 | s1[i] = toupper(s2[i]); 14 | } 15 | 16 | if (isupper(s2[i])) { 17 | cntA += 1; 18 | s1[i] = tolower(s2[i]); 19 | } 20 | 21 | if (isdigit(s2[i])) { 22 | cnt1 += 1; 23 | s1[i] = s2[i]; 24 | } 25 | i++; 26 | } 27 | printf("小寫字母: %d 個\n大寫字母:%d 個\n數字: %d 個\n", cnta, cntA, cnt1); 28 | printf("The oringinal string is:%s\n大小寫互換 : %s", s2, s1); 29 | } 30 | -------------------------------------------------------------------------------- /1411131047/22-10-12.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int facto(int); 5 | double expo(int); 6 | int power(int, int); 7 | 8 | int main(void) 9 | { 10 | printf("expo\n"); 11 | expo(10); 12 | printf("power\n"); 13 | printf_s("%d\n", power(2, 4)); 14 | } 15 | 16 | 17 | int facto(int y) 18 | { 19 | int a1=1; 20 | for (int i = 1; i <= y; ++i) { 21 | a1 *= i; 22 | } 23 | return a1; 24 | } 25 | 26 | double expo(int x) { 27 | double x1 = 1; 28 | for (int j = 1; j <= x; ++j) { 29 | x1 += 1.0/facto(j); 30 | printf_s("%lf\n", x1); 31 | } 32 | return x1; 33 | } 34 | 35 | int power(int x, int y) { 36 | int asw=1; 37 | for (int i = 1; i <= y; ++i) { 38 | asw *= x; 39 | } 40 | return asw; 41 | } -------------------------------------------------------------------------------- /1411131003/week3 (2): -------------------------------------------------------------------------------- 1 | int main( void ) 2 | { 3 | printf( "Enter three integers,and i will tell you\n" ); 4 | printf( "the sum, average. product, the largest and the smallest values: " ); 5 | 6 | int a, b, c, largest = 0, smallest = 9999; 7 | 8 | scanf( "%d" "%d" "%d", &a, &b, &c ); 9 | 10 | if (a >= b) { 11 | if (a >= c) 12 | largest = a; 13 | else 14 | largest = b; 15 | } // end if 16 | else if (c > b) { 17 | largest = c; 18 | } // end if 19 | else { 20 | largest = b; 21 | } // end if 22 | 23 | if (a >= b) { 24 | smallest = b; 25 | }// end if 26 | if (b >= a) { 27 | smallest = a; 28 | }//end if 29 | 30 | printf("Sum is % d\n",num1,) 31 | -------------------------------------------------------------------------------- /1411131007/week4-1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main( void ) 4 | { 5 | 6 | unsigned int passes = 0; 7 | unsigned int failures = 0; 8 | unsigned int student = 1; 9 | int result; 10 | 11 | while ( result != -1 ) { 12 | 13 | printf("Enter result ( 1=pass,2=fail,-1=abort): " ); 14 | scanf( "%d", &result ); 15 | 16 | if ( result == 1 ) 17 | passes++; 18 | else 19 | failures++; 20 | 21 | student = student + 1; 22 | } 23 | 24 | printf( "Passed %u\n", passes ); 25 | printf( "Failed %u\n", failures ); 26 | printf( "pass percentage: %.2f",(float)passes/student); 27 | 28 | if ((float)passes/student >= 0.8 ) { 29 | puts( "Bonus to instructor!" ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /week/week6/Random Seed usage: -------------------------------------------------------------------------------- 1 | // Fig. 5.13: fig05_13.c 2 | // Randomizing die-rolling program. 3 | #include 4 | #include 5 | 6 | int main(void) 7 | {unsigned int i; 8 | unsigned int seed; // number used to seed the random number generator 9 | 10 | printf("%s", "Enter seed: "); 11 | scanf("%u", &seed); // note %u for unsigned int 12 | 13 | srand(seed); // seed the random number generator 14 | 15 | // loop 10 times 16 | for (i = 1; i <= 10; ++i) { 17 | 18 | // pick a random number from 1 to 6 and output it 19 | printf("%10d", 1 + (rand() % 6)); 20 | 21 | // if counter is divisible by 5, begin a new line of output 22 | if (i % 5 == 0) { 23 | puts(""); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /1411131029/week7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fac(int); 4 | 5 | int main() 6 | { 7 | int n; 8 | scanf_s("%d", &n); 9 | for (int i = 0; i <= n; i++) { 10 | printf("%d", fac(i)); 11 | } 12 | printf("\n"); 13 | printf("%d\n", fac(n)); 14 | 15 | //迭代方式 16 | 17 | printf("Q2\n"); 18 | scanf_s("%d", &n); 19 | int n1 = 0, n2 = 1, asw; 20 | 21 | if (n <= 1)printf("%d", n); 22 | 23 | else 24 | { 25 | for (int i = 2; i <= n; i++) { 26 | asw = n1 + n2; 27 | n1 = n2; 28 | n2 = asw; 29 | } 30 | printf("%d", asw); 31 | } 32 | 33 | } 34 | 35 | //遞迴方式 36 | int fac(int n) { 37 | if (n <= 1)return n; 38 | 39 | else return fac(n - 1) + fac(n - 2); 40 | } 41 | -------------------------------------------------------------------------------- /1411131001/week6: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | int main(void) 5 | { 6 | unsigned int i; 7 | unsigned int n,m,temp; // number used to seed the random number generator 8 | 9 | printf("Enter n: "); 10 | scanf_s("%u", &n); // note %u for unsigned int 11 | 12 | srand(n); // seed the random number generator 13 | 14 | // loop 10 times 15 | for (i = 1; i <= pow(10,n); ++i) { 16 | temp = pow(10, n); 17 | m = rand() % temp; 18 | // pick a random number from 1 to 6 and output it 19 | printf("%10lf",(double)m/pow(10,n)); 20 | 21 | // if counter is divisible by 5, begin a new line of output 22 | if (i % 5 == 0) { 23 | puts(""); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /1411131003/week10 (1)費伯納: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 5 3 | 4 | void modifyArray(int b[], size_t size); 5 | 6 | int main(void) 7 | { 8 | // use initializer list to initialize array n 9 | int n[SIZE] = { 19, 3, 15, 7, 11 }, i, j; 10 | 11 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 12 | 13 | // for each element of array n, output a bar of the histogram 14 | for (i = 0; i < SIZE; ++i) { 15 | printf("%7u%13d ", i, n[i]); 16 | 17 | modifyArray(n, n[i]); 18 | 19 | } 20 | } 21 | 22 | void modifyArray(int b[], size_t size) 23 | { 24 | for (size_t j = 1; j <=size; ++j) { // print one bar 25 | printf("%c", '*'); 26 | } 27 | puts(""); // end a histogram bar with a newline 28 | 29 | } 30 | -------------------------------------------------------------------------------- /1411131015/week6: -------------------------------------------------------------------------------- 1 | // Fig. 5.13: fig05_13.c 2 | // Randomizing die-rolling program. 3 | #include 4 | #include 5 | #include 6 | int main(void) 7 | {unsigned int i; 8 | unsigned int n,m,temp; // number used to seed the random number generator 9 | 10 | printf("Enter n (n<5): "); 11 | scanf("%u", &n); // note %u for unsigned int 12 | 13 | 14 | 15 | // loop 10 times 16 | for (i = 1; i <= pow(10,n); ++i) { 17 | temp=pow(10,n); 18 | m=rand() % temp; 19 | // pick a random number from 1 to 6 and output it 20 | printf("%lf", (double)m/pow(10,n)); 21 | 22 | // if counter is divisible by 5, begin a new line of output 23 | if (i % 5 == 0) { 24 | puts(""); 25 | } 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /1411131019/practice1: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #define SIZE 5 //定義SIZE的值為5,在編譯之前電腦會先掃描程式,將所有出現SIZE的部份替換為5 4 | void star(int b[], int);//告知編譯器此程式之中有一個副程式存在 5 | 6 | int main(void) 7 | { // n[0] n[1] n[2] n[3] n[4] 8 | int n[SIZE] = { 19, 3, 15, 7, 11 }, i, j;//設定陣列n的元素 9 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 10 | 11 | for (i = 0; i < SIZE; ++i) { 12 | printf("%7u%13d ", i, n[i]);//列印出陣列n 13 | star(n, n[i]);//呼叫副程式star,並將陣列n、n[i]=元素值傳送給副程式 14 | puts(""); //換行 15 | } 16 | } 17 | void star(int b[], int size)//將n陣列傳送給b陣列,n[i]傳送給size 18 | { 19 | int j; 20 | for (j = 0; j < size; ++j) { 21 | printf("%c", '*');//%c:字元char,需加單引號'' 22 | } 23 | } 24 | //在主程式之中SIZE要用大寫,副程式用小寫 25 | -------------------------------------------------------------------------------- /1411131021/11/23-W11: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 10 3 | 4 | int main(void) 5 | { 6 | int a[SIZE] = {2,6,4,8,10,12,89,68,45,37}; 7 | 8 | puts("Data items in original order"); 9 | 10 | for (size_t i = 0; i < SIZE; ++i) { 11 | printf("%4d", a[i]); 12 | } 13 | 14 | for (unsigned int pass = 1; pass < SIZE; ++pass) { 15 | 16 | for (size_t i = 0; i < SIZE - 1; ++i) { 17 | 18 | if(a[i] > a[i + 1]) { 19 | int hold = a[i]; 20 | a[i] = a[i + 1]; 21 | a[i + 1] = hold; 22 | } 23 | } 24 | } 25 | 26 | puts("\nDaata items in ascending order"); 27 | 28 | for(size_t i = 0; i < SIZE; ++i) { 29 | printf("%4d", a[i]); 30 | } 31 | 32 | puts(""); 33 | } 34 | -------------------------------------------------------------------------------- /1411131021/W7-2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fac(int); 4 | 5 | int main() { 6 | //Q1. 7 | int n; 8 | scanf_s("%d", &n); 9 | for (int i = 0; i <= n; i++) { 10 | printf_s("%d ", fac(i)); 11 | } 12 | printf_s("\n"); 13 | printf_s("%d\n", fac(n)); 14 | 15 | //迭代方式 16 | 17 | printf_s("Q2\n"); 18 | scanf_s("%d", &n); 19 | int n1 = 0, n2 = 1, asw; 20 | 21 | if (n <= 1)printf_s("%d ", n); 22 | 23 | else 24 | { 25 | for (int i = 2; i <= n; i++) { 26 | asw = n1 + n2; 27 | n1 = n2; 28 | n2 = asw; 29 | } 30 | printf_s("%d ", asw); 31 | } 32 | } 33 | 34 | //遞迴方式 35 | int fac(int n) { 36 | if (n <= 1) return n; 37 | 38 | else return fac(n - 1) + fac(n - 2); 39 | } 40 | -------------------------------------------------------------------------------- /1411131039/1116Q2: -------------------------------------------------------------------------------- 1 | #include 2 | #define RESPONSES_SIZE 40 3 | #define FREQUENCY_SIZE 11 4 | 5 | void respon(int freq[],int resp[]); 6 | int main(void) 7 | { 8 | int frequency[FREQUENCY_SIZE] = {0},rating; 9 | int responses[RESPONSES_SIZE] = {1, 2, 6, 4, 8, 5, 9, 7, 8, 10, 10 | 1, 6, 3, 8, 6, 10, 3, 8, 2, 7, 6, 5, 7, 6, 8, 6, 7, 5, 6, 6, 11 | 5, 6, 7, 5, 6, 4, 8, 6, 8, 10}; 12 | respon(frequency,responses); 13 | printf("%s%17s\n", "Rating","Frequency"); 14 | for (rating = 1; rating < FREQUENCY_SIZE; ++rating) { 15 | printf("%6d%17d\n",rating, frequency[rating]); 16 | } 17 | } 18 | void respon(int freq[],int resp[]){ 19 | int answer; 20 | for (answer = 0; answer 3 | #include 4 | #include 5 | int main(void) 6 | { 7 | unsigned int i; 8 | unsigned int n,m,temp; // number used to seed the random number generator 9 | 10 | printf("%s", "Enter n: "); 11 | scanf_s("%u", &n); // note %u for unsigned int 12 | srand(n); // seed the random number generator 13 | 14 | // loop 10 times 15 | for (i = 1; i <= 1000; ++i) { 16 | temp = pow(10, n); 17 | 18 | m = rand() % temp; 19 | // pick a random number from 1 to 6 and output it 20 | printf("%10lf", (double)m/pow(10,n)); 21 | 22 | // if counter is divisible by 5, begin a new line of output 23 | if (i % 5 == 0) { 24 | puts(""); 25 | } 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /1411131035/week7費伯納西: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fac(int); 4 | 5 | int main() { 6 | //Q1. 7 | int n; 8 | scanf_s("%d", &n); 9 | for (int i = 0; i <= n; i++) { 10 | printf_s("%d ", fac(i)); 11 | } 12 | printf_s("\n"); 13 | printf_s("%d\n", fac(n)); 14 | 15 | //迭代方式 16 | 17 | printf_s("Q2\n"); 18 | scanf_s("%d", &n); 19 | int n1 = 0, n2 = 1, asw; 20 | 21 | if (n <= 1)printf_s("%d ", n); 22 | 23 | else 24 | { 25 | for (int i = 2; i <= n; i++) { 26 | asw = n1 + n2; 27 | n1 = n2; 28 | n2 = asw; 29 | } 30 | printf_s("%d ", asw); 31 | } 32 | } 33 | 34 | //遞迴方式 35 | int fac(int n) { 36 | if (n <= 1) return n; 37 | 38 | else return fac(n - 1) + fac(n - 2); 39 | } 40 | -------------------------------------------------------------------------------- /1411131047/22-10-26.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fac(int); 4 | 5 | 6 | int main() { 7 | //Q1. 8 | int n; 9 | scanf_s("%d", &n); 10 | for (int i = 0; i <= n; i++) { 11 | printf_s("%d ", fac(i)); 12 | } 13 | printf_s("\n"); 14 | printf_s("%d\n", fac(n)); 15 | 16 | //Q2 17 | 18 | printf_s("Q2\n"); 19 | scanf_s("%d", &n); 20 | int n1 = 0, n2 = 1, asw; 21 | 22 | if (n <= 1)printf_s("%d ", n); 23 | 24 | else 25 | { 26 | for (int i = 2; i <= n; i++) { 27 | asw = n1 + n2; 28 | n1 = n2; 29 | n2 = asw; 30 | } 31 | printf_s("%d ", asw); 32 | } 33 | } 34 | 35 | 36 | 37 | int fac(int n) { 38 | if (n <= 1) return n; 39 | 40 | else return fac(n - 1) + fac(n - 2); 41 | } -------------------------------------------------------------------------------- /week/week7/Solution2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fac(int); 4 | 5 | int main() { 6 | //Q1. 7 | int n; 8 | scanf_s("%d", &n); 9 | for (int i = 0; i <= n; i++) { 10 | printf_s("%d ", fac(i)); 11 | } 12 | printf_s("\n"); 13 | printf_s("%d\n", fac(n)); 14 | 15 | //迭代方式 16 | 17 | printf_s("Q2\n"); 18 | scanf_s("%d", &n); 19 | int n1 = 0, n2 = 1, asw; 20 | 21 | if (n <= 1)printf_s("%d ", n); 22 | 23 | else 24 | { 25 | for (int i = 2; i <= n; i++) { 26 | asw = n1 + n2; 27 | n1 = n2; 28 | n2 = asw; 29 | } 30 | printf_s("%d ", asw); 31 | } 32 | } 33 | 34 | //遞迴方式 35 | int fac(int n) { 36 | if (n <= 1) return n; 37 | 38 | else return fac(n - 1) + fac(n - 2); 39 | } 40 | -------------------------------------------------------------------------------- /1411131003/week16(2)大小寫互換: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | char s1[] = "DkR5tf7Iu"; 7 | char s2[] = "DkR5tf7Iu"; 8 | 9 | int i = 0; 10 | 11 | int a = 0; 12 | int A = 0; 13 | int e = 0; 14 | 15 | while (s2[i] != '\0') { 16 | if (islower(s2[i])) { 17 | 18 | a += 1; 19 | s1[i] = toupper(s2[i]); 20 | } 21 | 22 | if (isupper(s2[i])) { 23 | A += 1; 24 | s1[i] = tolower(s2[i]); 25 | } 26 | 27 | if (isdigit(s2[i])) { 28 | e += 1; 29 | s1[i] = s2[i]; 30 | } 31 | i++; 32 | } 33 | printf("小寫數量共%d個\n大寫數量共%d個\n數字數量共%d個\n", a, A, e); 34 | puts(""); 35 | printf("原本的字串:%s\n大小寫互換後的字串=%s", s2, s1); 36 | puts(""); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /1411131009/1019: -------------------------------------------------------------------------------- 1 | // Fig. 5.13: fig05_13.c 2 | // Randomizing die-rolling program. 3 | #include 4 | #include 5 | #include 6 | 7 | int main(void) 8 | { 9 | unsigned int i; 10 | unsigned int n,m,temp; // number used to seed the random number generator 11 | 12 | printf("enter n(n<5):"); 13 | scanf_s("%u", &n); // note %u for unsigned int 14 | 15 | 16 | 17 | // loop 10 times 18 | for (i = 1; i<=pow (10, n); ++i) { 19 | temp = pow(10, n); 20 | m = rand() % temp; 21 | // pick a random number from 1 to 6 and output it 22 | printf("%1f", (double)m / pow(10, n)); 23 | 24 | // if counter is divisible by 5, begin a new line of output 25 | if (i % 5 == 0) { 26 | puts(""); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /1411131047/22-11-16-p2-2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define RESPONSES_SIZE 40 3 | #define FREQUENCY_SIZE 11 4 | 5 | void fre(int R[], int F[], int, int); 6 | 7 | 8 | int main() { 9 | int ar[RESPONSES_SIZE] = { 1, 2, 6, 4, 8, 5, 9, 7, 8, 10,1, 6, 3, 8, 6, 10, 3, 8, 2, 7, 6, 5, 7, 6, 8, 6, 7, 5, 6, 6,5, 6, 7, 5, 6, 4, 8, 6, 8, 10 }, rat[FREQUENCY_SIZE] = { 0 }, i; 10 | printf_s("%s%17s\n", "Rating", "Frequency"); 11 | fre(ar, rat, RESPONSES_SIZE, FREQUENCY_SIZE); 12 | } 13 | 14 | void fre(int R[], int F[], int RSize, int FSize) { 15 | int i,j; 16 | for (i = 0; i < RSize; i++) { 17 | F[R[i]] += 1; 18 | } 19 | for (i = 1; i < FSize; i++) { 20 | printf_s("%6d%17d%4s", i, F[i],""); 21 | for (j = 0; j < F[i]; j++) { 22 | printf_s("*"); 23 | } 24 | puts(""); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /1411131059/2.16: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int integer1; 6 | int integer2; 7 | 8 | printf("Enter first integer\n"); 9 | scanf_s("%d", &integer1); 10 | 11 | printf("Enter second integer\n"); 12 | scanf_s("%d", &integer2); 13 | 14 | int sum; 15 | sum = integer1 + integer2; 16 | 17 | int product; 18 | product = integer1 * integer2; 19 | 20 | int difference; 21 | difference = integer1 - integer2; 22 | 23 | int quotient; 24 | quotient = integer1 / integer2; 25 | 26 | int remainder; 27 | remainder = integer1 % integer2; 28 | 29 | printf("sum is %d\n", sum); 30 | printf("product is %d\n", product); 31 | printf("difference is %d\n", difference); 32 | printf("quotient is %d\n", quotient); 33 | printf("remainder is %d\n", remainder); 34 | } 35 | -------------------------------------------------------------------------------- /1411131049/w6: -------------------------------------------------------------------------------- 1 | // Fig. 5.13: fig05_13.c 2 | // Randomizing die-rolling program. 3 | #include 4 | #include 5 | #include 6 | int main(void) 7 | {unsigned int i; 8 | unsigned int n,m,temp; // number used to seed the random number generator 9 | 10 | printf("Enter n: "); 11 | scanf("%u", &n); // note %u for unsigned int 12 | 13 | srand(n); // seed the random number generator 14 | 15 | // loop 10 times 16 | for (i = 1; i <= pow(10,n); ++i) { 17 | temp=pow(10,n); 18 | m=rand()%temp; 19 | 20 | // pick a random number from 1 to 6 and output it 21 | printf("%10.4lf%",(double)m/pow(10,n)); 22 | 23 | // if counter is divisible by 5, begin a new line of output 24 | if (i % 5 == 0) { 25 | puts(""); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /phillip0085/1116 ps1 幾個星星: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 5 3 | 4 | void modifyArray(int b[], size_t size); 5 | 6 | // function main begins program execution 7 | int main(void) 8 | { 9 | // use initializer list to initialize array n 10 | int n[SIZE] = { 19, 3, 15, 7, 11 }, i; 11 | 12 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 13 | 14 | // for each element of array n, output a bar of the histogram 15 | for (i = 0; i < SIZE; ++i) { 16 | printf("%7u%13d ", i, n[i]); 17 | 18 | // end a histogram bar with a newline 19 | 20 | modifyArray(n, n[i]); 21 | 22 | } 23 | } 24 | 25 | void modifyArray(int b[], size_t size) 26 | { 27 | 28 | for (size_t j = 1; j <= size; ++j) { // print one bar 29 | printf("%c", '*'); 30 | } 31 | puts(""); 32 | } 33 | -------------------------------------------------------------------------------- /1411131041/week4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | unsigned int passes = 0; 6 | unsigned int failures = 0; 7 | unsigned int student = 0; 8 | int result; 9 | printf( "Enter result ( 1=pass,2=fail,-1=end ): "); 10 | scanf_s("%d", &result); 11 | while (result != -1) { 12 | if (result == 1) 13 | passes++; 14 | 15 | else 16 | failures++; 17 | 18 | student++; 19 | printf( "Enter result ( 1=pass,2=fail,-1=end ): "); 20 | scanf_s("%d", &result); 21 | } 22 | printf("Passed %u\n", passes); 23 | printf("Failed %u\n", failures); 24 | printf("passes %.2f%%\n", (float)passes / student*100); 25 | if ((float)passes/student >= 0.8) { 26 | puts("Bonus to instructor!"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /1411131035/week4及格率計算2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | unsigned int passes = 0; 6 | unsigned int failures = 0; 7 | unsigned int student = 0; 8 | int result; 9 | printf( "Enter result ( 1=pass,2=fail,-1=end ): "); 10 | scanf_s("%d", &result); 11 | while (result != -1) { 12 | if (result == 1) 13 | passes++; 14 | 15 | else 16 | failures++; 17 | 18 | student++; 19 | printf( "Enter result ( 1=pass,2=fail,-1=end ): "); 20 | scanf_s("%d", &result); 21 | } 22 | printf("Passed %u\n", passes); 23 | printf("Failed %u\n", failures); 24 | printf("passes %.2f%%\n", (float)passes / student*100); 25 | if ((float)passes/student >= 0.8) { 26 | puts("Bonus to instructor!"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /1411131007/week16-1: -------------------------------------------------------------------------------- 1 | 題目一 2 | 給定一個字串,先計算且印出字串中的大、小寫與數字的數量,之後將字串中的大、小寫互換之後,再將互換後的字串印出。 3 | 4 | #include 5 | #include 6 | 7 | int main (){ 8 | char s1[] = "Hd4hTrh2b5"; 9 | char s2[] = "Hd4hTrh2b5"; 10 | 11 | int i = 0, cnta = 0, cntA = 0, cnt1 = 0; 12 | 13 | while (s2[i] != '\0') { 14 | if (islower (s2[i]) ){ 15 | cnta += 1; 16 | s1[i] = toupper (s2[i]); 17 | } 18 | 19 | if (isupper (s2[i]) ){ 20 | cntA += 1; 21 | s1[i] = tolower (s2[i]); 22 | } 23 | 24 | if (isdigit (s2[i]) ){ 25 | cnt1 += 1; 26 | s1[i] = s2[i]; 27 | } 28 | i++; 29 | } 30 | printf ("小寫字母 %d 個,大寫字母 %d 個,數字 %d 個\n", cnta, cntA, cnt1); 31 | printf ("原字串:%s,大小寫互換 : %s", s2, s1); 32 | } 33 | -------------------------------------------------------------------------------- /1411131037/week4: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | double principal = 0; // starting principal 7 | double rate = .05;// annual interest rate 8 | int period = 0; 9 | printf("輸入第一年本金:"); 10 | scanf_s("%lf", &principal); 11 | printf("輸入定存利率(%%)"); 12 | scanf_s("%lf", &rate); 13 | printf("輸入定存時長(年):"); 14 | scanf_s("%d", &period); 15 | // output table column heads 16 | printf( "Year", "Amount on deposit"); 17 | 18 | // calculate amount on deposit for each of ten years 19 | for (unsigned int year = 1; year <= 10; ++year) { 20 | 21 | // calculate new amount for specified year 22 | double amount = principal * pow(1.0 + rate, year); 23 | 24 | // output one table row 25 | printf("%4u%21.2f\n", year, amount); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /1411131021/1116-W10-1: -------------------------------------------------------------------------------- 1 | #include 2 | // Fig. 6.8: fig06_08.c 3 | // Displaying a histogram. 4 | #include 5 | #define SIZE 5 6 | 7 | // function main begins program execution 8 | void a(int n[], int star); 9 | int main(void) 10 | { 11 | // use initializer list to initialize array n 12 | int n[SIZE] = { 19, 3, 15, 7, 11 }, i, j; 13 | 14 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 15 | 16 | // for each element of array n, output a bar of the histogram 17 | for (i = 0; i < SIZE; ++i) { 18 | printf("%7u%13d ", i, n[i]); 19 | 20 | for (j = 1; j <= n[i]; ++j) { // print one bar 21 | printf("%c", '*'); 22 | } 23 | 24 | puts(""); // end a histogram bar with a newline 25 | } 26 | void a(int n[], int star); 27 | for (j = 1; j <= n[i]; ++j) { // print one bar 28 | printf("%c", '*'); 29 | } 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /1411131041/week6-test: -------------------------------------------------------------------------------- 1 | // Fig. 5.13: fig05_13.c 2 | // Randomizing die-rolling program. 3 | #include 4 | #include 5 | #include 6 | int main(void) 7 | { 8 | unsigned int i; 9 | unsigned int n,m,temp; // number used to seed the random number generator 10 | 11 | printf( "Enter n "); 12 | scanf_s("%u", &n); // note %u for unsigned int 13 | 14 | srand(n); // seed the random number generator 15 | 16 | // loop 10 times 17 | for (i = 1; i <= pow(10,n); ++i) { 18 | temp = pow(10, n); 19 | m = rand() % temp; 20 | // pick a random number from 1 to 6 and output it 21 | printf("%10.*lf",n, double(m)/pow(10,n)); 22 | 23 | // if counter is divisible by 5, begin a new line of output 24 | if (i % 5 == 0) { 25 | puts(""); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /phillip0085/1228ps1-2大小寫互換: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | int main(void) { 6 | 7 | char s1[] = "Hd4hTrh2b5"; 8 | char s2[] = "Hd4hTrh2b5"; 9 | 10 | int i = 0; 11 | 12 | int cnta = 0; 13 | int cntA = 0; 14 | int cnt1 = 0; 15 | 16 | while (s2[i] != '\0') { 17 | if (islower(s2[i])) { 18 | 19 | cnta += 1; 20 | s1[i] = toupper(s2[i]); 21 | } 22 | 23 | if (isupper(s2[i])) { 24 | cntA += 1; 25 | s1[i] = tolower(s2[i]); 26 | } 27 | 28 | if (isdigit(s2[i])) { 29 | cnt1 += 1; 30 | s1[i] = s2[i]; 31 | } 32 | i++; 33 | } 34 | printf("小寫共%d個\n大寫共%d個\n數字共%d個\n", cnta, cntA, cnt1); 35 | puts(" "); 36 | printf("原本字串:%s\n大小寫互換=%s", s2, s1); 37 | puts(" "); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /1411131003/week6 (1): -------------------------------------------------------------------------------- 1 | // Fig. 5.13: fig05_13.c 2 | // Randomizing die-rolling program. 3 | #include 4 | #include 5 | #include 6 | 7 | int main(void) 8 | { 9 | unsigned int i; 10 | unsigned int n, m, temp; // number used to seed the random number generator 11 | 12 | printf("Enter n(n<5): "); 13 | scanf_s("%u", &n); // note %u for unsigned int 14 | 15 | srand(n); // seed the random number generator 16 | 17 | // loop 10 times 18 | for (i = 1; i <= pow(10,n); ++i) { 19 | temp = pow(10, n); 20 | m = rand() % temp; 21 | // pick a random number from 1 to 6 and output it 22 | printf("%10lf", (double)m / pow(10, n)); 23 | 24 | // if counter is divisible by 5, begin a new line of output 25 | if (i % 5 == 0) { 26 | puts(""); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /phillip0085/1116 ps2 學生餐廳評分統計: -------------------------------------------------------------------------------- 1 | #include 2 | #define RESPONSES_SIZE 40 // define array sizes 3 | #define FREQUENCY_SIZE 11 4 | 5 | void respon(int freq[], int resp[]); 6 | 7 | // function main begins program execution 8 | int main(void) 9 | { 10 | int frequency[FREQUENCY_SIZE] = { 0 }, rating; 11 | int response[RESPONSES_SIZE] = { 1,2,6,4,8,5,9,7,8,10,1,6,3,8,6,10,3,8,2,7,6,5,6,8,6,7,5,6,6,5,6,7,5,6,4,8,6,8,10 }; 12 | 13 | respon(frequency, response); 14 | printf("%s%17s\n", "Rating", "Frequency"); 15 | 16 | for (rating = 1; rating < FREQUENCY_SIZE; ++rating) { 17 | printf("%6d%17d\n", rating, frequency[rating]); 18 | } 19 | } 20 | 21 | void respon(int freq[], int resp[]) 22 | { 23 | int answer; 24 | for (answer = 0; answer < RESPONSES_SIZE; ++answer) { 25 | ++freq[resp[answer]]; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /1411131013/week6: -------------------------------------------------------------------------------- 1 | // Fig. 5.12: fig05_12.c 2 | // Rolling a six-sided die 60,000,000 times. 3 | // Fig. 5.13: fig05_13.c 4 | // Randomizing die-rolling program. 5 | #include 6 | #include 7 | #include 8 | 9 | int main(void) 10 | { 11 | unsigned int i; 12 | unsigned int n,m,e,temp; // number used to seed the random number generator 13 | 14 | printf("Enter n: "); 15 | scanf("%d", &n); // note %u for unsigned int 16 | e=pow(10,n); 17 | // loop 10 times 18 | for (i = 1; i <= e; ++i) { 19 | temp=pow(10,n); 20 | m=rand() % temp; 21 | // pick a random number from 1 to 6 and output it 22 | printf("%lf", (double)m/pow(10,n)); 23 | 24 | // if counter is divisible by 5, begin a new line of output 25 | if (i % 5 == 0) { 26 | puts(""); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /1411131019/1019-rand: -------------------------------------------------------------------------------- 1 | // Fig. 5.13: fig05_13.c 2 | // Randomizing die-rolling program. 3 | #include 4 | #include 5 | #include 6 | 7 | int main(void) 8 | { 9 | unsigned int i; 10 | unsigned int n,m,temp; // number used to seed the random number generator 11 | 12 | printf("Enter n (n<5): "); 13 | scanf_s("%u", &n); // note %u for unsigned int 14 | 15 | //srand(n); // seed the random number generator 16 | 17 | // loop 10 times 18 | for (i = 1; i <= pow(10,n); ++i) { 19 | temp = pow(10, n); 20 | m = rand() % temp; 21 | // pick a random number from 1 to 6 and output it 22 | printf("%10lf", (double)m/pow(10,n)); 23 | 24 | // if counter is divisible by 5, begin a new line of output 25 | if (i % 5 == 0) { 26 | puts(""); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /1411131033/week10-2: -------------------------------------------------------------------------------- 1 | #include 2 | #define RESPONSES_SIZE 40 3 | #define FREQUENCY_SIZE 11 4 | 5 | void modifyArray(int freq[],int resp[]); 6 | 7 | int main(void) 8 | { 9 | int frequency[FREQUENCY_SIZE] = {0}; 10 | int responses[RESPONSES_SIZE] = {1, 2, 6, 4, 8, 5, 9, 7, 8, 10, 11 | 1, 6, 3, 8, 6, 10, 3, 8, 2, 7, 6, 5, 7, 6, 8, 6, 7, 5, 6, 6, 12 | 5, 6, 7, 5, 6, 4, 8, 6, 8, 10}; 13 | modifyArray(frequency,responses); 14 | 15 | printf("%s%17s\n", "Rating", "Frequency"); 16 | 17 | 18 | for (size_t rating = 1; rating < FREQUENCY_SIZE; ++rating) { 19 | printf("%6d%17d\n", rating, frequency[rating]); 20 | } 21 | } 22 | void modifyArray(int freq[],int resp[]){ 23 | 24 | int answer; 25 | for (size_t answer = 0; answer < RESPONSES_SIZE; ++answer) { 26 | ++freq[resp[answer]]; 27 | } 28 | 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /1411131059/綫性搜尋: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 10 3 | 4 | int search(int a[], int id); 5 | 6 | int main(void) 7 | { 8 | int a[SIZE] = { 2,6,4,8,10,12,89,68,45,37 }, ID, j; 9 | int c[SIZE] = { 66,67,66,70,73,74,75,75,62,32 }; 10 | 11 | puts("Data items in original order"); 12 | 13 | for (int i = 0; i < SIZE; ++i) 14 | { 15 | printf("\n"); 16 | printf("%4d", a[i]); 17 | printf("%4d", c[i]); 18 | } 19 | 20 | puts(""); 21 | 22 | printf("\nInput student ID: "); 23 | scanf_s("%d", &ID); 24 | j = search(a, ID); 25 | if (j < 0) 26 | { 27 | printf("Student %d not found!", ID); 28 | } 29 | else 30 | { 31 | printf("Student %d got %d!", ID, c[j]); 32 | } 33 | } 34 | 35 | int search(int a[], int id) 36 | { 37 | int i; 38 | for (i = 0; i < SIZE; i++) 39 | { 40 | if (id == a[i]) 41 | { 42 | return i; 43 | } 44 | } 45 | return -1; 46 | } 47 | -------------------------------------------------------------------------------- /1411131039/1123Q2: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 10 3 | void test(int b[], int d[]); 4 | void s(int b[], int d[],int id); 5 | int main() 6 | { 7 | int a[SIZE] = { 2,6,4,8,10,12,89,68,45,37 }; 8 | int c[SIZE] = { 66,67,66,70,73,74,75,75,62,32 }; 9 | printf("原始順序\n"); 10 | for (int p = 0; p < SIZE; p++) { 11 | printf("%4d  ", a[p]); 12 | printf("%4d\n", c[p]); 13 | } 14 | printf("\n請輸入要查詢成績的座號:"); 15 | int n; 16 | scanf_s("%d", &n); 17 | s(a,c,n); 18 | } 19 | void s(int b[], int d[],int id) { 20 | int j = 0; 21 | for (int i = 0; i <= SIZE - 1; i++) { 22 | if (id == b[i]) { 23 | printf("id=%d,score=%d", b[i], d[i]); 24 | break; 25 | } 26 | else { 27 | j++; 28 | } 29 | } 30 | if (j >= 9) 31 | printf("id %d not found!",id); 32 | } 33 | -------------------------------------------------------------------------------- /week/week10/Practice 1: -------------------------------------------------------------------------------- 1 | 題目1: 修改課本306、307頁的程式fig06_06.c,印出柱狀圖的程式碼放入一個副程式中,並透過陣列傳遞的方式,將兩個陣列與size傳送到副程式中印出。 2 | 3 | // Fig. 6.8: fig06_08.c 4 | // Displaying a histogram. 5 | #include 6 | #define SIZE 5 7 | 8 | // function main begins program execution 9 | int main(void) 10 | { 11 | // use initializer list to initialize array n 12 | int n[SIZE] = {19, 3, 15, 7, 11},i,j; 13 | 14 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 15 | 16 | // for each element of array n, output a bar of the histogram 17 | for (i = 0; i < SIZE; ++i) { 18 | printf("%7u%13d ", i, n[i]) ; 19 | 20 | for ( j = 1; j <= n[i]; ++j) { // print one bar 21 | printf("%c", '*'); 22 | } 23 | 24 | puts(""); // end a histogram bar with a newline 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /1411131009/1228-1: -------------------------------------------------------------------------------- 1 | // ConsoleApplication1.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。 2 | //計算字串中大、小寫、數字數量,再將大小寫互換後印出。 3 | 4 | #include 5 | #include 6 | 7 | 8 | int main() 9 | { 10 | char s1[] = "ABCdefgh12345"; 11 | char s2[] = "ABCdefgh12345"; 12 | int i = 0; 13 | int a = 0; 14 | int A = 0; 15 | int number = 0; 16 | 17 | while (s2[i] != '\0') { 18 | 19 | if (islower(s2[i])) { 20 | a += 1; 21 | s1[i] = toupper(s2[i]); 22 | } 23 | 24 | if (isupper(s2[i])) { 25 | A+=1; 26 | s1[i] = tolower(s2[i]); 27 | } 28 | 29 | if (isdigit(s2[i])) { 30 | number += 1; 31 | } 32 | i++; 33 | } 34 | 35 | printf("%d個小寫\n", a); 36 | printf("%d個大寫\n", A); 37 | printf("%d個數字\n", number); 38 | printf("%s\n", s1); 39 | } 40 | -------------------------------------------------------------------------------- /1411131019/1228-1: -------------------------------------------------------------------------------- 1 | // ConsoleApplication1.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。 2 | //計算字串中大、小寫、數字數量,再將大小寫互換後印出。 3 | 4 | #include 5 | #include 6 | 7 | 8 | int main() 9 | { 10 | char s1[] = "ABCdefgh12345"; 11 | char s2[] = "ABCdefgh12345"; 12 | int i = 0; 13 | int a = 0; 14 | int A = 0; 15 | int number = 0; 16 | 17 | while (s2[i] != '\0') { 18 | 19 | if (islower(s2[i])) { 20 | a += 1; 21 | s1[i] = toupper(s2[i]); 22 | } 23 | 24 | if (isupper(s2[i])) { 25 | A+=1; 26 | s1[i] = tolower(s2[i]); 27 | } 28 | 29 | if (isdigit(s2[i])) { 30 | number += 1; 31 | } 32 | i++; 33 | } 34 | 35 | printf("%d個小寫\n", a); 36 | printf("%d個大寫\n", A); 37 | printf("%d個數字\n", number); 38 | printf("%s\n", s1); 39 | } 40 | -------------------------------------------------------------------------------- /1411131059/p153: -------------------------------------------------------------------------------- 1 | // Fig. 4.6: fig04_06.c 2 | // Calculating compound interest 3 | #include 4 | #include 5 | 6 | int main(void) 7 | { 8 | double principal; 9 | printf("輸入第一年本金:"); 10 | scanf("%lf", &principal) ; 11 | double rate; 12 | printf("輸入定存利率(%%):"); 13 | scanf("%lf", &rate) ; 14 | int period; 15 | printf("輸入定存多久(年):"); 16 | scanf("%d", &period) ; 17 | 18 | // output table column heads 19 | printf("%4s%21s\n","Year", "Amount on deposit"); 20 | 21 | // calculate amount on deposit for each of ten years 22 | for (unsigned int year = 0; year <= period; ++year) { 23 | 24 | // calculate new amount for specified year 25 | double amount = principal * pow(1.0 + rate, year); 26 | 27 | // output one table row 28 | printf("%4u%21.2f\n", year, amount); 29 | 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /1411131001/week16 Q1: -------------------------------------------------------------------------------- 1 | /*題目一 2 | 給定一個字串,先計算且印出字串中的大、小寫與數字的數量,之後將字串中的大、小寫互換之後,再將互換後的字串印出。*/ 3 | 4 | #include 5 | #include 6 | 7 | int main(void) { 8 | 9 | char s1[] = "Hd4hTrh2b5"; 10 | char s2[] = "Hd4hTrh2b5"; 11 | 12 | int i = 0; 13 | 14 | int cnta = 0; 15 | int cntA = 0; 16 | int cnt1 = 0; 17 | while (s2[i] != '\0') { 18 | if (islower(s2[i])) { 19 | 20 | cnta += 1; 21 | s1[i] = toupper(s2[i]); 22 | } 23 | 24 | if (isupper(s2[i])) { 25 | cntA += 1; 26 | s1[i] = tolower(s2[i]); 27 | } 28 | 29 | if (isdigit(s2[i])) { 30 | cnt1 += 1; 31 | s1[i] = s2[i]; 32 | } 33 | i++; 34 | } 35 | printf("小寫共%d個\n大寫共%d個\n數字共%d個\n", cnta, cntA, cnt1); 36 | printf("原本字串:%s互換大小寫=%s", s2, s1); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /1411131049/w11 線性搜尋: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 10 3 | int search(int a[],int ); 4 | int main(void) 5 | { 6 | int a[SIZE] = { 2, 6, 4, 8, 10, 12, 89, 68, 45, 37 }; 7 | int c[SIZE] = { 66,67,66,70,73,74,75,75,62,32 },ID,i,j; 8 | 9 | puts("Data items in original order"); 10 | for (int i = 0; i < SIZE; ++i) { 11 | printf("\n"); 12 | printf("%4d", a[i]); 13 | printf("%4d", c[i]); 14 | } 15 | puts(""); 16 | 17 | printf("\nInput student ID: "); 18 | scanf("%d", &ID); 19 | 20 | j = search(a,ID); 21 | if (j < 0) 22 | 23 | printf("student %d not found!", ID); 24 | 25 | else printf("Student %d got %d!",ID, c[j]); 26 | 27 | puts(""); 28 | } 29 | 30 | int search(int a[],int id) 31 | { 32 | int i; 33 | for (i = 0; i < SIZE; i++) 34 | if (id == a[i]) 35 | return i; 36 | 37 | return -1; 38 | } 39 | -------------------------------------------------------------------------------- /1411031035/week 6: -------------------------------------------------------------------------------- 1 | // Fig. 5.13: fig05_13.c 2 | // Randomizing die-rolling program. 3 | #include 4 | #include 5 | #include 6 | int main(void) 7 | { 8 | unsigned int i; 9 | unsigned int n; // number used to seed the random number generator 10 | unsigned int temp,m; 11 | 12 | printf("%s", "Enter seed: "); 13 | scanf_s("%d", &n); // note %u for unsigned int 14 | 15 | srand(n); // n the random number generator 16 | 17 | // loop 10 times 18 | for (i = 1; i <= pow(10,n); ++i) { 19 | 20 | // pick a random number from 1 to 6 and output it 21 | temp =pow(10, n); 22 | m = rand() % temp; 23 | printf("%10.*lf",n ,double(m)/ pow(10, n)); 24 | 25 | // if counter is divisible by 5, begin a new line of output 26 | if (i % 5 == 0) { 27 | puts(""); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /1411131007/week5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int facto(int); // function prototype 原型宣告 4 | double expo(int); 5 | double power(int,int); 6 | 7 | int main(void) 8 | {int x; 9 | 10 | for (x = 1; x <= 10; ++x) { 11 | printf("%d ", facto(x)); 12 | printf("\n value of e is :%lf",expo(x)); 13 | printf("\n power of 2 is :%.1lf",power(2,x)); 14 | } 15 | 16 | puts(""); 17 | } 18 | 19 | 20 | int facto(int y) 21 | {int result=1,i; 22 | for(i=1;i<=y;i++) 23 | result=result*i; 24 | return result; 25 | } 26 | 27 | double expo(int y) 28 | {int result=1,i; 29 | double expo=1; 30 | for(i=1;i<=y;i++){ 31 | result=result*i; 32 | expo=expo+(1.0/result); 33 | } 34 | return expo; 35 | } 36 | 37 | 38 | double power(int x, int y){ 39 | int result=1,i; 40 | for(i=1;i<=y;i++) 41 | result=result*x; 42 | return result; 43 | } 44 | Footer 45 | -------------------------------------------------------------------------------- /1411131033/week6: -------------------------------------------------------------------------------- 1 | // Fig. 5.13: fig05_13.c 2 | // Randomizing die-rolling program. 3 | #include 4 | #include 5 | #include 6 | int main(void) 7 | { 8 | unsigned int i; 9 | unsigned int n; // number used to seed the random number generator 10 | unsigned int temp,m; 11 | 12 | printf("%s", "Enter seed: "); 13 | scanf_s("%d", &n); // note %u for unsigned int 14 | 15 | srand(n); // n the random number generator 16 | 17 | // loop 10 times 18 | for (i = 1; i <= pow(10,n); ++i) { 19 | 20 | // pick a random number from 1 to 6 and output it 21 | temp =pow(10, n); 22 | m = rand() % temp; 23 | printf("%10.*lf",n ,double(m)/ pow(10, n)); 24 | 25 | // if counter is divisible by 5, begin a new line of output 26 | if (i % 5 == 0) { 27 | puts(""); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /phillip0085/1019p1 random: -------------------------------------------------------------------------------- 1 | //輸入整數n<5,要傳回10的n次方組亂數,亂數值介於0.9999…9~0.0000...1, n為精確值(小數後第幾位 (要用使用者自訂函數) 2 | 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | int main(void) 9 | { 10 | unsigned int i; 11 | unsigned int n, m, t; // number used to seed the random number generator 12 | 13 | printf("Enter n, n<5: "); 14 | scanf_s("%u", &n); // note %u for unsigned int 15 | 16 | srand(n); // seed the random number generator 17 | 18 | // loop 10 times 19 | for (i = 1; i <= pow(10, n); ++i) { 20 | t = pow(10, n); 21 | m = rand() % t; 22 | 23 | // pick a random number from 1 to 6 and output it 24 | printf("%10lf", (double)m / pow(10, n)); 25 | 26 | // if counter is divisible by 5, begin a new line of output 27 | if (i % 5 == 0) { 28 | puts(""); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /phillip0085/1228 ps1-1合成函數大小寫互換: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | 6 | 7 | int main(void) { 8 | 9 | int (*func[2])(int) = { toupper, tolower}; 10 | 11 | char s1[] = "Hd4hTrh2b5"; 12 | char s2[] = "Hd4hTrh2b5"; 13 | 14 | int i = 0; 15 | 16 | int cnta = 0; 17 | int cntA = 0; 18 | int cnt1 = 0; 19 | 20 | while (s2[i] != '\0') { 21 | if (islower(s2[i])) { 22 | 23 | cnta += 1; 24 | s1[i] = func[0](s2[i]); 25 | } 26 | 27 | if (isupper(s2[i])) { 28 | cntA += 1; 29 | s1[i] = func[1](s2[i]); 30 | } 31 | 32 | if (isdigit(s2[i])) { 33 | cnt1 += 1; 34 | } 35 | i++; 36 | } 37 | printf("小寫共%d個\n大寫共%d個\n數字共%d個\n", cnta, cntA, cnt1); 38 | puts(" "); 39 | printf("原本字串:%s\n大小寫互換=%s", s2, s1); 40 | puts(" "); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /1411131009/1116-2: -------------------------------------------------------------------------------- 1 | #include 2 | #define RESPONSES_SIZE 40 3 | #define FREQUENCY_SIZE 11 4 | void respon(int freq[], int resp[]); 5 | 6 | int main(void) 7 | { 8 | 9 | int frequency[FREQUENCY_SIZE] = { 0 },rating; 10 | 11 | 12 | int responses[RESPONSES_SIZE] = { 1, 2, 6, 4, 8, 5, 9, 7, 8, 10, 13 | 1, 6, 3, 8, 6, 10, 3, 8, 2, 7, 6, 5, 7, 6, 8, 6, 7, 5, 6, 6, 14 | 5, 6, 7, 5, 6, 4, 8, 6, 8, 10 }; 15 | 16 | 17 | respon(frequency, responses); 18 | 19 | 20 | printf("%s%17s\n", "Rating", "Frequency"); 21 | 22 | 23 | for ( rating = 1; rating < FREQUENCY_SIZE; ++rating) { 24 | printf("%6d%17d\n", rating, frequency[rating]); 25 | } 26 | } 27 | void respon(int freq[], int resp[]) 28 | {int answer; 29 | 30 | for ( answer = 0; answer < RESPONSES_SIZE; ++answer) { 31 | ++freq[resp[answer]]; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /1411131027/week5: -------------------------------------------------------------------------------- 1 | // Fig. 5.13: fig05_13.c 2 | // Randomizing die-rolling program. 3 | #include 4 | #include 5 | #include 6 | 7 | int main(void) 8 | { 9 | unsigned int i; 10 | unsigned int n,m ,temp; // number used to seed the random number generator 11 | 12 | printf("Enter n: (< 5)"); 13 | scanf_s("%u", &n); // note %u for unsigned int 14 | 15 | srand(n); // seed the random number generator 16 | 17 | // loop 10 times 18 | for (i = 1; i <= pow(10,n); ++i) { 19 | temp = pow(10, n); 20 | m = rand() % temp; 21 | printf("%.*lf ",n,(double)m/pow(10,n) ); 22 | //printf("%lf ", (double)m / pow(10, n)); 23 | //printf("%.3lf ",(double)m/pow(10,n) ); 24 | // if counter is divisible by 5, begin a new line of output 25 | if (i % 5 == 0) { 26 | puts(""); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /1411131029/week6-1: -------------------------------------------------------------------------------- 1 | // Fig. 5.13: fig05_13.c 2 | // Randomizing die-rolling program. 3 | #include 4 | #include 5 | #include 6 | 7 | int main(void) 8 | { 9 | unsigned int i; 10 | unsigned int n,m,temp; // number used to seed the random number generator 11 | 12 | printf("%s", "Enter n: ");//n<5 13 | scanf_s("%u", &n); // note %u for unsigned int 14 | 15 | srand(n); // seed the random number generator 16 | 17 | // loop 10 times 18 | for (i = 1; i <= pow(10,n); ++i) {//傳回10的n次方組 19 | temp = pow(10, n); 20 | m = rand() % temp; 21 | // pick a random number from 1 to 6 and output it 22 | 23 | printf("%10lf",(double)m/pow(10,n));//傳回10的n次方組 24 | 25 | // if counter is divisible by 5, begin a new line of output 26 | if (i % 5 == 0) { 27 | puts(""); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /1411131039/0928Q1: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) { 5 | printf("Enter three different integers:"); 6 | int n1,n2,n3; 7 | scanf("%d %d %d",&n1,&n2,&n3); 8 | int sum,average,product,min,max; 9 | sum=n1+n2+n3; 10 | average=sum/3; 11 | product=n1*n2*n3; 12 | min=n1; 13 | max=n1; 14 | if(minn2){ 31 | if(max>n3){ 32 | } 33 | else{ 34 | max=n3; 35 | } 36 | } 37 | else{ 38 | max=n2; 39 | if(max>n3){ 40 | } 41 | else{ 42 | min=n3; 43 | } 44 | } 45 | printf("Sum is %d\n",sum); 46 | printf("Average is %d\n",average); 47 | printf("Product is %d\n",product); 48 | printf("Smallest is %d\n",min); 49 | printf("Largest is %d",max); 50 | } 51 | -------------------------------------------------------------------------------- /1411131041/week4-test: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | unsigned int passes = 0; 6 | unsigned int failures = 0; 7 | unsigned int student = 0; 8 | int result; 9 | printf("%s", "Enter result ( 1=pass,2=fail,-1=end ): "); 10 | scanf_s("%d", &result); 11 | while (result != -1) 12 | { 13 | if (result == 1) { 14 | passes++; 15 | } 16 | else { 17 | failures++; 18 | } 19 | 20 | student++; 21 | printf("%s", "Enter result ( 1=pass,2=fail,-1=end ): "); 22 | scanf_s("%d", &result); 23 | } 24 | 25 | printf("Passed %u\n", passes); 26 | printf("Failed %u\n", failures); 27 | printf("passes %2.f%%\n", (float)passes / student * 100); 28 | if ((float)passes/student >= 0.8) 29 | { 30 | puts("Bonus to instructor!"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /1411131009/1012: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int facto(int); // function prototype 原型宣告 4 | double expo(int); 5 | int power(int, int); 6 | 7 | int main(void) 8 | { 9 | int x; 10 | // loop 10 times and calculate and output square of x each time 11 | for (x = 1; x <= 15; ++x) { 12 | printf("%d ", facto(x)); // function call 13 | printf("\n value of e is:1f", expo(x)); 14 | 15 | } 16 | 17 | puts(""); 18 | } 19 | 20 | // square function definition returns the square of its parameter 21 | int facto(int y) // y is a copy of the argument to the function 22 | { 23 | int result = 1, i; 24 | for (i = 1; i <= y; i++) 25 | result = result * i; 26 | return result; // returns the square of y as an int 27 | } 28 | double expo(int y) 29 | { 30 | int result = 1, i; 31 | double expo = 1; 32 | for (i = 1; i <= y; i++) 33 | result = result * i; 34 | expo = expo + (1 / result); 35 | } 36 | -------------------------------------------------------------------------------- /1411131019/1228-3: -------------------------------------------------------------------------------- 1 | // ConsoleApplication3.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。 2 | //寫一個程式,能將字串中一個或多個浮點數取出,並分別印出 3 | //使用strtod、strncat 4 | //s1=abc2.34ababc3.8gh4.4xyz 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | int main() 12 | { 13 | char s1[] = "abc2.34ababc3.8gh4.4xyz"; //建立一個字串名為s1 14 | char* s1ptr = &s1[0]; //建立一個指標s1ptr指向字串s1的開頭位置 15 | 16 | while (*s1ptr != '\0') { //當指標s1ptr尚未只到結束符號前執行以下程式 17 | if (!isdigit(*s1ptr) ){ //如果s1指向的內容不是數字-------!isdigit:不是數字 18 | s1ptr++; //將1ptr指向的位置往後一個 19 | } 20 | else { //如果s1指向的內容是數字 21 | double d = strtod(s1ptr, &s1ptr); //將字串s1轉換為double 22 | printf("%.2f\n", d); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /1411131041/week5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int facto(int); 4 | double expo(int); 5 | double power(int, int); 6 | 7 | int main(void) 8 | { 9 | int x; 10 | 11 | for (x = 1; x <= 10; ++x) { 12 | printf("%d ", facto(x)); 13 | printf("\n value of e is :%lf", expo(x)); 14 | printf("\n power of 2 is :%.1lf", power(2, x)); 15 | } 16 | 17 | 18 | puts(""); 19 | } 20 | 21 | int facto(int y) 22 | { 23 | int result = 1, i; 24 | for (i = 1; i <= y; i++) 25 | result = result * i; 26 | return result; 27 | } 28 | 29 | double expo(int y) 30 | { 31 | int result = 1, i; 32 | double expo = 1; 33 | for (i = 1; i <= y; i++) { 34 | result = result * i; 35 | expo = expo + (1.0 / result); 36 | } 37 | return expo; 38 | } 39 | 40 | 41 | double power(int x, int y) { 42 | int result = 1, i; 43 | for (i = 1; i <= y; i++) 44 | result = result * x; 45 | return result; 46 | } 47 | -------------------------------------------------------------------------------- /1411131021/W4-1: -------------------------------------------------------------------------------- 1 | // Fig. 4.6: fig04_06.c 2 | // Calculating compound interest 3 | #include 4 | #include 5 | 6 | int main(void) 7 | { 8 | double principal; // starting principal 9 | double rate; 10 | int period; 11 | // annual interest rate 12 | printf("輸入第一年本金:"); 13 | scanf_s("%1f", &principal); 14 | printf("輸入定存利率(%%):"); 15 | scanf_s("%1f", &rate); 16 | printf("輸入定存多久:"); 17 | scanf_s("%d", &period); 18 | 19 | // output table column heads 20 | printf("%4s%21s\n", "Year", "Amount on deposit"); 21 | 22 | // calculate amount on deposit for each of ten years 23 | for (unsigned int year = 1; year <= 10; ++year) { 24 | 25 | // calculate new amount for specified year 26 | double amount = principal * pow(1.0 + rate, year); 27 | 28 | // output one table row 29 | printf("%4u%21.2f\n", year, amount); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /phillip0085/1005p2 本金利率: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | int main(void) 6 | { 7 | double principal; // starting principal 8 | double rate; // annual interest rate 9 | int period; 10 | 11 | printf("輸入第一年本金:"); 12 | scanf_s("%lf", &principal); 13 | 14 | printf("輸入定存利率(%%):"); 15 | scanf_s("%lf", &rate); 16 | 17 | printf("輸入定存多久(年):"); 18 | scanf_s("%d", &period); 19 | 20 | 21 | 22 | // output table column heads 23 | printf("%4s%21s\n", "Year", "Amount on deposit"); 24 | 25 | // calculate amount on deposit for each of ten years 26 | for (unsigned int year = 1; year <= period; ++year) { 27 | 28 | 29 | // calculate new amount for specified year 30 | double amount = principal * pow(1.0 + rate, year); 31 | 32 | 33 | // output one table row 34 | printf("%4u%21.2f\n", year, amount); 35 | 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /1411131035/week5階層函數+副程式2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int facto(int); 4 | double expo(int); 5 | double power(int, int); 6 | 7 | int main(void) 8 | { 9 | int x; 10 | 11 | for (x = 1; x <= 10; ++x) { 12 | printf("%d ", facto(x)); 13 | printf("\n value of e is :%lf", expo(x)); 14 | printf("\n power of 2 is :%.1lf", power(2, x)); 15 | } 16 | 17 | 18 | puts(""); 19 | } 20 | 21 | int facto(int y) 22 | { 23 | int result = 1, i; 24 | for (i = 1; i <= y; i++) 25 | result = result * i; 26 | return result; 27 | } 28 | 29 | double expo(int y) 30 | { 31 | int result = 1, i; 32 | double expo = 1; 33 | for (i = 1; i <= y; i++) { 34 | result = result * i; 35 | expo = expo + (1.0 / result); 36 | } 37 | return expo; 38 | } 39 | 40 | 41 | double power(int x, int y) { 42 | int result = 1, i; 43 | for (i = 1; i <= y; i++) 44 | result = result * x; 45 | return result; 46 | } 47 | -------------------------------------------------------------------------------- /1411131007/week10-2: -------------------------------------------------------------------------------- 1 | //題目2: 修改課本305頁的程式fig06_05.c,將印出問卷結果的程式碼放入一個副程式中,並透過陣列傳遞的方式,將陣列與size傳送到副程式中印出。 2 | 3 | #include 4 | #define RESPONSES_SIZE 40 5 | #define FREQUENCY_SIZE 11 6 | void respon(int freq[], int resp[]); 7 | 8 | int main(void) 9 | { 10 | int frequency[FREQUENCY_SIZE] = { 0 }; 11 | 12 | int responses[RESPONSES_SIZE] = { 1, 2, 6, 4, 8, 5, 9, 7, 8, 10, 13 | 1, 6, 3, 8, 6, 10, 3, 8, 2, 7, 6, 5, 7, 6, 8, 6, 7, 5, 6, 6, 14 | 5, 6, 7, 5, 6, 4, 8, 6, 8, 10 }; 15 | 16 | respon(frequency, responses); 17 | 18 | printf("%s%17s\n", "Rating", "Frequency"); 19 | 20 | for (size_t rating = 1; rating < FREQUENCY_SIZE; ++rating) { 21 | printf("%6d%17d\n", rating, frequency[rating]); 22 | } 23 | } 24 | void respon(int freq[], int resp[]) 25 | { int answer; 26 | for ( answer = 0; answer < RESPONSES_SIZE; ++answer) { 27 | ++freq[resp[answer]]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /1411131023/week 10 P2: -------------------------------------------------------------------------------- 1 | 修改課本305頁的程式fig06_05.c,將印出問卷結果的程式碼放入一個副程式中,並透過陣列傳遞的方式,將陣列與size傳送到副程式中印出。 2 | #include 3 | #define responses_size 40 4 | #define frequency_size 11 5 | 6 | void respon(int freq[], int resp[]); 7 | 8 | int main(void) 9 | { 10 | int frequency[frequency_size] = {0}, rating; 11 | int responses[responses_size] = { 1, 2, 6, 4, 8, 5, 9, 7, 8, 10, 12 | 1, 6, 3, 8, 6, 10, 3, 8, 2, 7, 6, 5, 7, 6, 8, 6, 7, 5, 6, 6, 13 | 5, 6, 7, 5, 6, 4, 8, 6, 8, 10 }; 14 | 15 | respon(frequency, responses); 16 | printf("%s%17s\n", "Rating", "Frequency"); 17 | 18 | for ( rating = 1; rating < frequency_size; ++rating) { 19 | printf("%6d%17d\n", rating, frequency[rating]); 20 | } 21 | } 22 | 23 | void respon(int freq[], int resp[]) 24 | { 25 | int answer; 26 | for (answer = 0; answer < responses_size ; ++answer) { 27 | ++freq[resp[answer]]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /1411131029/week4-2: -------------------------------------------------------------------------------- 1 | // Fig. 4.6: fig04_06.c 2 | // Calculating compound interest 3 | #include 4 | #include 5 | 6 | int main(void) 7 | { 8 | double principal ; // starting principal 9 | double rate; 10 | int period; 11 | // annual interest rate 12 | printf("輸入第一年本金:"); 13 | scanf_s("%lf", &principal); 14 | printf("輸入定存利率(%%):"); 15 | scanf_s("%lf", &rate); 16 | printf("輸入定存多久(年):"); 17 | scanf_s("%d", &period); 18 | 19 | // output table column heads 20 | printf( "%4u%21.2f\n","Year", "Amount on deposit"); 21 | 22 | // calculate amount on deposit for each of ten years 23 | for (unsigned int year = 1; year <= period; ++year) { 24 | 25 | // calculate new amount for specified year 26 | double amount = principal * pow(1.0 + rate, year); 27 | 28 | // output one table row 29 | printf("%4u%21.2f\n", year, amount); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /1411131001/week 11 1-2: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 10 3 | 4 | int linearSearch(int id[], int sc[],int stu); 5 | int main(void) 6 | { 7 | int i, temp; 8 | int a[SIZE] = { 2,6,4,8,10,12,89,68,45,37 }; 9 | int c[SIZE] = { 66,67,66,70,73,74,75,78,62,32 }; 10 | 11 | puts("Data items in original order"); 12 | 13 | for ( i = 0; i < SIZE; ++i) { 14 | printf("\n"); 15 | printf("%4d", a[i]); 16 | printf("%4d", c[i]); 17 | } 18 | puts("\nplease iput the id:"); 19 | scanf_s("%d", &temp); 20 | if (linearSearch(a, c, temp) < 0) 21 | { 22 | printf("id no found"); 23 | return 0; 24 | } 25 | printf("id=%d and score=%d", temp,c[linearSearch (a, c,temp)]); 26 | 27 | puts(""); 28 | } 29 | int linearSearch(int id[], int sc[], int stu) { 30 | int i; 31 | for (i = 0; i < SIZE; i++) 32 | if (id[i] == stu) return i; 33 | return -1; 34 | } 35 | -------------------------------------------------------------------------------- /1411131005/2: -------------------------------------------------------------------------------- 1 | // Fig. 5.3: fig05_03.c 2 | // Creating and using a programmer-defined function. 3 | #include 4 | #include 5 | 6 | int facto(int); // function prototype 原型宣告 7 | int power(int, int); 8 | double expo(int); 9 | 10 | 11 | 12 | int main(void) 13 | { 14 | int x; 15 | // loop 10 times and calculate and output square of x each time 16 | for (x = 1; x <= 10; ++x) { 17 | printf("%d ", facto(x)); // function call 18 | printf("\n value of e is :%lf", expo(x)); 19 | printf("\n the power is :%LF", power(2, y)); 20 | } 21 | 22 | puts(""); 23 | 24 | } 25 | 26 | int facto(int y) 27 | { 28 | int result = 1, i; 29 | for (i = 1; i <= y; i++) { 30 | result = result * i; 31 | return result; 32 | } 33 | } 34 | 35 | int power (int x,int y) 36 | { 37 | int result = 1; 38 | for (i = 1; i <= y; i++) 39 | { 40 | result = result * i; 41 | power = pow(2, result); 42 | return power; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /1411131019/1005: -------------------------------------------------------------------------------- 1 | // ConsoleApplication1.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。 2 | // 3 | 4 | #include 5 | #include 6 | 7 | int main(void) 8 | { 9 | unsigned int year = 1; 10 | int principal=0; // starting principal 11 | double rate=0 ; // annual interest rate 12 | double period=0 ; 13 | printf("請輸入第一年本金"); 14 | scanf_s("%lf", &principal); 15 | printf("請輸入定存利率(%%):"); 16 | scanf_s("%lf", &rate); 17 | printf("請輸入定存多久(年)"); 18 | scanf_s("%d", &period); 19 | 20 | 21 | printf("%4s%21s\n", "Year", "Amount on deposit"); 22 | 23 | // calculate amount on deposit for each of ten years 24 | for (unsigned int year = 1; year <= period; ++year) { 25 | 26 | // calculate new amount for specified year 27 | double amount = principal * pow(1.0 + rate,period); 28 | 29 | // output one table row 30 | printf("%4u%21.2f\n", year, amount); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /1411131033/3: -------------------------------------------------------------------------------- 1 | { 2 | int num1; 3 | int num2; 4 | int num3; 5 | int largest; 6 | int smallest; 7 | int sum; 8 | int average; 9 | int mul; 10 | printf("請輸入三個數值\n"); 11 | scanf_s("%d" "%d" "%d", &num1, &num2, &num3); 12 | if (num1 > num2 and num1 > num3) { 13 | largest = num1; 14 | } 15 | else if (num2 > num1 and num2 > num3) { 16 | largest = num2; 17 | } 18 | else if (num3 > num1 and num3 > num2) { 19 | largest = num3; 20 | } 21 | else if (num1 < num2 and num1 < num3) { 22 | smallest = num1; 23 | } 24 | else if (num2 < num1 and num2 < num3) { 25 | smallest = num2; 26 | } 27 | else if (num3 < num1 and num3 < num2) { 28 | smallest = num3; 29 | } 30 | sum = num1+num2+num3; 31 | average = (num1 + num2 + num3) / 3; 32 | mul = num1 * num2 * num3; 33 | printf("最大值為%d\n", largest); 34 | printf("最小值為%d\n", smallest); 35 | printf("總合為%d\n", sum); 36 | printf("平均為%d\n", average); 37 | printf("乘積為%d\n", mul); 38 | } 39 | -------------------------------------------------------------------------------- /1411131035/week6隨機數產生_5.10章: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | unsigned int i; 8 | unsigned int n, AA, BB; // number used to seed the random number generator 9 | 10 | printf("%s", "Enter n<5: "); 11 | scanf_s("%u", &n); // note %u for unsigned int 12 | 13 | srand(n); // seed the random number generator 14 | BB = pow(10, n); 15 | 16 | if (n>5) 17 | { 18 | return 0; 19 | 20 | } 21 | else 22 | { 23 | for (i = 1; i <= BB; ++i) 24 | { 25 | 26 | AA = rand() % BB; 27 | // pick a random number from 1 to 6 and output it 28 | printf("%20g", (double)AA / BB); 29 | 30 | // if counter is divisible by 5, begin a new line of output 31 | if (i % 5 == 0) 32 | { 33 | puts(""); 34 | } 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /1411131003/week11 (2)搜尋成績: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 10 3 | void sort(int a[], int c[], int size); 4 | int search(int a[], int); 5 | int main(void) 6 | { 7 | int a[SIZE] = { 2, 6, 4, 8, 10, 12, 89, 68, 45, 37 }; 8 | int c[SIZE] = { 66,67,66,70,73,74,75,75,62,32 }, ID, i, j = 0; 9 | 10 | puts("Data items in original order"); 11 | 12 | for (size_t i = 0; i < SIZE; ++i) { 13 | printf("%4d", a[i]); 14 | } 15 | printf("\n"); 16 | for (size_t i = 0; i < SIZE; ++i) { 17 | printf("%4d", c[i]); 18 | } 19 | 20 | printf("\nInput student ID: "); 21 | scanf_s("%d", &ID); 22 | 23 | j = search(a, ID); 24 | if (j >= 9) printf("student %d not found!", ID); 25 | else printf("Student %d got %d!", a[j], c[j]); 26 | puts(""); 27 | } 28 | 29 | int search(int a[], int id) 30 | { 31 | int i; 32 | for (i = 0; i < SIZE; i++) 33 | if (id == a[i]) 34 | return i; 35 | } 36 | -------------------------------------------------------------------------------- /1411131017/week 5: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int facto(int); // function prototype 原型宣告 5 | double expo(int); 6 | double power(int, int); 7 | 8 | int main(void) 9 | { 10 | int x; 11 | // loop 10 times and calculate and output square of x each time 12 | for (x = 1; x <= 10; ++x) { 13 | printf("%d ", facto(x)); // function call 14 | } 15 | printf("\n value of e is :%1f;", expo(10)); 16 | puts(""); 17 | } 18 | 19 | // square function definition returns the square of its parameter 20 | int facto(int y) // y is a copy of the argument to the function 21 | {int result = 1, i; 22 | for (i = 1; i <= y; i++) 23 | result = result * i; 24 | return result; // returns the square of y as an int 25 | } 26 | 27 | double expo(int y) 28 | { 29 | int result = 1, i; 30 | double expo = 1; 31 | for (i = 1; i <= y; i++) { 32 | result = result * 1; 33 | expo = expo + (1.0 / result); 34 | } 35 | return expo; 36 | } 37 | -------------------------------------------------------------------------------- /1411131005/1: -------------------------------------------------------------------------------- 1 | // Fig. 5.3: fig05_03.c 2 | // Creating and using a programmer-defined function. 3 | #include 4 | #include 5 | 6 | int facto(int); // function prototype 原型宣告 7 | int power(int, int); 8 | double expo(int); 9 | 10 | 11 | 12 | int main(void) 13 | { 14 | int x; 15 | // loop 10 times and calculate and output square of x each time 16 | for (x = 1; x <= 10; ++x) { 17 | printf("%d ", facto(x)); // function call 18 | printf("\n value of e is :%lf", expo(x)); 19 | } 20 | 21 | puts(""); 22 | 23 | } 24 | 25 | int facto(int y) 26 | { 27 | int result = 1, i; 28 | for (i = 1; i <= y; i++) { 29 | result = result * i; 30 | return result; 31 | } 32 | } 33 | 34 | double expo(int y) 35 | {int result = 1, i; 36 | double expo = 1; 37 | for (i = 1; i <= y; i++) 38 | { 39 | result = result * i; 40 | expo = expo + (1.0 / result); 41 | } 42 | 43 | return expo; // returns the square of y as an int 44 | } 45 | -------------------------------------------------------------------------------- /1411131011/week 4-2: -------------------------------------------------------------------------------- 1 | // Fig. 4.6: fig04_06.c 2 | // Calculating compound interest 3 | #include 4 | #include 5 | 6 | int main(void) 7 | { 8 | double principal = 5000.0; // starting principal 9 | double rate = 0.02; // annual interest rate 10 | int period; 11 | 12 | printf("輸入第一年本金:"); 13 | scanf_s("%lf", &principal); 14 | 15 | printf("輸入定存利率(%%):"); 16 | scanf_s("%lf", &rate); 17 | 18 | printf("輸入定存多久(年):"); 19 | scanf_s("%d", &period); 20 | 21 | 22 | // output table column heads 23 | printf("%4s%21s\n", "Year", "Amount on deposit"); 24 | 25 | // calculate amount on deposit for each of ten years 26 | for (unsigned int year = 1; year <= period; ++year) { 27 | 28 | // calculate new amount for specified year 29 | double amount = principal * pow(1.0 + rate, year); 30 | 31 | // output one table row 32 | printf("%4u%21.2f\n", year, amount); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /1411131011/week5: -------------------------------------------------------------------------------- 1 | // Fig. 5.3: fig05_03.c 2 | // Creating and using a programmer-defined function. 3 | #include 4 | #include 5 | 6 | double expo(int terms); 7 | double power(int x, int y); 8 | 9 | int main(void) 10 | { 11 | int x; 12 | // loop 10 times and calculate and output square of x each time 13 | for (x = 1; x <= 15; ++x) { 14 | printf("%d ", facto(x)); // function call 15 | } 16 | 17 | puts(""); 18 | } 19 | 20 | // square function definition returns the square of its parameter 21 | 22 | 23 | double expo(int y) // y is a copy of the argument to the function 24 | { 25 | int result = 1, i; 26 | double expo = 1; 27 | for (i = 1; i <= y; i++) 28 | 29 | expo = expo + (1.0 / result); 30 | return result; // returns the square of y as an int 31 | } 32 | 33 | printf("the value of 'e' is:%1f") 34 | 35 | double power(int x, int y) 36 | { 37 | int result = x, a; 38 | return result; 39 | } 40 | -------------------------------------------------------------------------------- /1411131059/Array Q2: -------------------------------------------------------------------------------- 1 | #include 2 | #define RESPONSES_SIZE 40 3 | #define FREQUENCY_SIZE 11 4 | 5 | void respon(int freq[],int resp[]); 6 | 7 | int main(void) 8 | { 9 | int frequency[FREQUENCY_SIZE] = {0}; 10 | 11 | int responses[RESPONSES_SIZE] = {1, 2, 6, 4, 8, 5, 9, 7, 8, 10, 12 | 1, 6, 3, 8, 6, 10, 3, 8, 2, 7, 6, 5, 7, 6, 8, 6, 7, 5, 6, 6, 13 | 5, 6, 7, 5, 6, 4, 8, 6, 8, 10}; 14 | 15 | printf("%s%15s%19s\n", "Rating", "Frequency","Histogram"); 16 | 17 | respon(frequency, responses); 18 | } 19 | 20 | void respon(int freq[],int resp[]) 21 | { 22 | for (int answer = 0; answer < RESPONSES_SIZE; ++answer) 23 | { 24 | ++freq[resp[answer]]; 25 | } 26 | for (int rating = 1; rating < FREQUENCY_SIZE; ++rating) 27 | { 28 | printf("%6d%13d ", rating, freq[rating]); 29 | 30 | for(int j=1;j<=freq[rating];++j) 31 | { 32 | printf("%c",'*'); 33 | } 34 | puts(""); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /1411031035/week 10 Q1: -------------------------------------------------------------------------------- 1 | // Fig. 6.8: fig06_08.c 2 | // Displaying a histogram. 3 | #include 4 | #define SIZE 5 5 | void modifyarray(int x[],int size); 6 | 7 | // function main begins program execution 8 | int main(void) 9 | { 10 | // use initializer list to initialize array n 11 | int n[SIZE] = { 19, 3, 15, 7, 11 }, i, j; 12 | 13 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 14 | 15 | // for each element of array n, output a bar of the histogram 16 | 17 | for (i = 0; i < SIZE; ++i) { 18 | printf("%7u%13d ", i, n[i]); 19 | 20 | modifyarray(n, n[i]); 21 | 22 | puts(""); // end a histogram bar with a newline 23 | } 24 | 25 | } 26 | void modifyarray(int x[], int size) 27 | { 28 | int j,i; 29 | for (j = 1; j <= size; ++j) 30 | { // print one bar 31 | printf("%c", '*'); 32 | } 33 | 34 | // end a histogram bar with a newline 35 | 36 | } 37 | -------------------------------------------------------------------------------- /1411131029/week11-Q1: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 10 3 | void sort(int id[], int sc[]); 4 | int main(void) { 5 | int i; 6 | int a[SIZE] = { 2,6,4,8,10,12,89,68,45,37 }; 7 | int score[SIZE] = { 76,85,63,62,98,91,88,85,69,71 }; 8 | puts("Data items in original order"); 9 | for ( i = 0; i < SIZE; ++i) { 10 | printf("\n"); 11 | printf("%4d", a[i]); 12 | printf("%4d", score[i]); 13 | } 14 | sort(a, score); 15 | puts("\nData items in ascending order"); 16 | for (i = 0; i < SIZE; ++i) { 17 | printf("\n"); 18 | printf("%4d", a[i]); 19 | printf("%4d", score[i]); 20 | } 21 | puts(""); 22 | } 23 | void sort(int id[], int sc[]) { 24 | int pass, i; 25 | for (pass=0; pass sc[i + 1]) { 28 | int hold = id[i]; 29 | id[i] = id[i + 1]; 30 | id[i + 1] = hold; 31 | 32 | hold = sc[i]; 33 | sc[i] = sc[i + 1]; 34 | sc[i + 1] = hold; 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /1411131053/6/6/6/6.cpp: -------------------------------------------------------------------------------- 1 | // 6.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。 2 | // 3 | 4 | #include 5 | #include 6 | #include 7 | int main(void) 8 | { 9 | unsigned int i; 10 | unsigned int n,m,temp; 11 | printf("Enter n:"); 12 | scanf_s("%u", &n); 13 | for (i = 1; i <= pow(10, n); ++i) { 14 | temp=pow(10,n); 15 | m = rand() % temp; 16 | printf("%10.*lf", n,(double)m / pow(10,n)); 17 | 18 | if (i % 5 == 0) { 19 | puts(""); 20 | } 21 | } 22 | 23 | 24 | } 25 | 26 | // 執行程式: Ctrl + F5 或 [偵錯] > [啟動但不偵錯] 功能表 27 | // 偵錯程式: F5 或 [偵錯] > [啟動偵錯] 功能表 28 | 29 | // 開始使用的提示: 30 | // 1. 使用 [方案總管] 視窗,新增/管理檔案 31 | // 2. 使用 [Team Explorer] 視窗,連線到原始檔控制 32 | // 3. 使用 [輸出] 視窗,參閱組建輸出與其他訊息 33 | // 4. 使用 [錯誤清單] 視窗,檢視錯誤 34 | // 5. 前往 [專案] > [新增項目],建立新的程式碼檔案,或是前往 [專案] > [新增現有項目],將現有程式碼檔案新增至專案 35 | // 6. 之後要再次開啟此專案時,請前往 [檔案] > [開啟] > [專案],然後選取 .sln 檔案 36 | -------------------------------------------------------------------------------- /phillip0085/1123 ps2 搜尋學生成績: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIZE 10 3 | 4 | 5 | int search(int a[], int); 6 | 7 | int main(void) 8 | { 9 | 10 | int a[SIZE] = { 2, 6, 4, 8, 10, 12, 89, 68, 45, 37 }; 11 | int c[SIZE] = { 66,67,66,70,73,74,75,75,62,32 }; 12 | int ID, i, j = 0; 13 | 14 | puts("Data items in original order"); 15 | 16 | for (size_t i = 0; i < SIZE; ++i) { 17 | printf("%4d", a[i]); 18 | } 19 | printf("\n"); 20 | for (size_t i = 0; i < SIZE; ++i) { 21 | printf("%4d", c[i]); 22 | } 23 | 24 | 25 | printf("\n\nInput student ID: "); 26 | scanf_s("%d", &ID); 27 | 28 | j = search(a, ID); 29 | if (j > 9) printf("Student %d not found!", ID); 30 | else printf("Student %d got %d!", a[j], c[j]); 31 | 32 | 33 | puts(""); 34 | } 35 | 36 | 37 | int search(int a[], int id) 38 | { 39 | int i; 40 | for (i = 0; i < SIZE; i++) 41 | if (id == a[i]) 42 | return i; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /1411131045/class-week6.cpp: -------------------------------------------------------------------------------- 1 | // class-week6.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。 2 | // 3 | 4 | #include 5 | #include 6 | #include 7 | int main(void) 8 | { 9 | unsigned int i; 10 | unsigned int n,m,temp; 11 | printf("Enter n: "); 12 | scanf_s("%u", &n); 13 | for (i = 1; i <=pow(10,n) ; ++i) { 14 | temp = pow(10, n); 15 | m = rand() % temp; 16 | printf("%10.*lf",n,(double)m /pow(10,n)); 17 | 18 | 19 | if (i % 5 == 0) { 20 | puts(""); 21 | } 22 | } 23 | } 24 | 25 | // 執行程式: Ctrl + F5 或 [偵錯] > [啟動但不偵錯] 功能表 26 | // 偵錯程式: F5 或 [偵錯] > [啟動偵錯] 功能表 27 | 28 | // 開始使用的提示: 29 | // 1. 使用 [方案總管] 視窗,新增/管理檔案 30 | // 2. 使用 [Team Explorer] 視窗,連線到原始檔控制 31 | // 3. 使用 [輸出] 視窗,參閱組建輸出與其他訊息 32 | // 4. 使用 [錯誤清單] 視窗,檢視錯誤 33 | // 5. 前往 [專案] > [新增項目],建立新的程式碼檔案,或是前往 [專案] > [新增現有項目],將現有程式碼檔案新增至專案 34 | // 6. 之後要再次開啟此專案時,請前往 [檔案] > [開啟] > [專案],然後選取 .sln 檔案 35 | -------------------------------------------------------------------------------- /1411131007/week3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main( void ) 4 | { 5 | printf( "輸入三個數值並得知總和、平均值、乘積、最大值和最小值: " ); 6 | 7 | int a, b, c; 8 | int largest=0, smallest=9999; 9 | 10 | scanf( "%d %d %d", &a, &b, &c ); 11 | 12 | if (a>=b) { 13 | if(a>=c) 14 | largest=a; 15 | else 16 | largest=b; 17 | } 18 | else if(c>b){ 19 | largest=c; 20 | } 21 | else{ 22 | largest=b; 23 | } 24 | 25 | 26 | 27 | if (a>=b) { 28 | smallest=b; 29 | } 30 | if (b>=a) { 31 | smallest=a; 32 | } 33 | if (c 2 | #define SIZE 10 3 | #define SIZE1 2 4 | 5 | void SWAP(int* Ptr1, int* Ptr2); 6 | void printAry(int ar[]); 7 | 8 | int main() { 9 | int* countPtr = NULL, * countPtr2 = NULL, i, j; 10 | int stuN[SIZE1][SIZE] = { {12,13,14,15,16,17,19,21,22,23 }, { 66,67,66,70,73,74,75,75,62,32 } }; 11 | printAry(stuN[0]); 12 | printAry(stuN[1]); 13 | for (i = 0; i < SIZE; i++) { 14 | for (j = 0; j < SIZE - i; j++) { 15 | if (stuN[1][j] < stuN[1][j + 1]) { 16 | SWAP(&stuN[1][j], &stuN[1][j + 1]); 17 | SWAP(&stuN[0][j], &stuN[0][j + 1]); 18 | } 19 | } 20 | } 21 | printAry(stuN[0]); 22 | printAry(stuN[1]); 23 | 24 | 25 | } 26 | 27 | 28 | void SWAP(int* cPtr, int* cPtr1) { 29 | int temp; 30 | temp = *cPtr; 31 | *cPtr = *cPtr1; 32 | *cPtr1 = temp; 33 | } 34 | 35 | void printAry(int ar[]) { 36 | int i; 37 | for (i = 0; i < SIZE; i++) { 38 | printf_s("%2d ", ar[i]); 39 | } 40 | puts(""); 41 | } -------------------------------------------------------------------------------- /1411131021/W3-2: -------------------------------------------------------------------------------- 1 | // Fig. 2.13: fig02_13.c 2 | // Using if statements, relational 3 | // operators, and equality operators 4 | #include 5 | 6 | // function main begins program execution 7 | int main( void ) 8 | { 9 | printf( "Enter a grade, and I will tell you\n" ); 10 | printf( "the results: " ); 11 | 12 | int num1; // first number to be read from user 13 | //int num2; // second number to be read from user 14 | 15 | scanf( "%d", &num1); // read two integers 16 | 17 | if ( num1 >=90 ) { //如果if括弧內的結果為true ,就會執行if的大括弧內的內容 18 | //如果if括弧內的結果為false ,就跳過if的大括弧內的內容 19 | puts("A"); 20 | } 21 | else if (num1 >=80 ) { 22 | puts("B"); 23 | } // end if 24 | else if (num1 >=70 ) { 25 | puts("C"); 26 | } // end if 27 | else if (num1 >=60 ) { 28 | puts("D"); 29 | } // end if 30 | else { 31 | puts("F"); 32 | } // end if 33 | return 0; 34 | } // end function main 35 | -------------------------------------------------------------------------------- /1411131021/W3-3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // function main begins program execution 4 | int main( void ) 5 | { 6 | printf( "Enter a grade, and I will tell you\n" ); 7 | printf( "the results: " ); 8 | 9 | int num1; // first number to be read from user 10 | //int num2; // second number to be read from user 11 | 12 | scanf( "%d", &num1); // read two integers 13 | 14 | if ( num1 >=90 ) { //如果if括弧內的結果為true ,就會執行if的大括弧內的內容 15 | //如果if括弧內的結果為false ,就跳過if的大括弧內的內容 16 | puts("A"); 17 | } 18 | else { 19 | if (num1 >=80 ) { 20 | puts("B"); 21 | } // end if 22 | else { 23 | if (num1 >=70 ) { 24 | puts("C"); 25 | } // end if 26 | else { 27 | if (num1 >=60 ) { 28 | puts("D"); 29 | } 30 | else{ 31 | puts("F"); 32 | } 33 | } 34 | } 35 | } // end if 36 | // end if 37 | return 0; 38 | } // end function main 39 | -------------------------------------------------------------------------------- /phillip0085/1123 ps1 泡泡成績排序: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #define SIZE 10 4 | 5 | void sort(int a[], int c[], int size); 6 | 7 | int main(void) { 8 | int a[SIZE] = { 2,6,4,8,10,12,89,68,45,37 }; 9 | int c[SIZE] = { 66,67,66,70,73,74,75,75,62,32 }; 10 | 11 | puts("Date items in original order"); 12 | 13 | int i; 14 | for (i = 0; i < SIZE; ++i) { 15 | printf("%4d", a[i]); 16 | printf("%4d", c[i]); 17 | puts(" "); 18 | } 19 | 20 | puts("\nDate items in ascending order"); 21 | sort(a, c, SIZE); 22 | 23 | for (i = 0; i < SIZE; ++i) { 24 | printf("%4d", a[i]); 25 | printf("%4d", c[i]); 26 | puts(" "); 27 | 28 | } 29 | } 30 | 31 | void sort(int a[], int c[], int size) 32 | { 33 | int pass, hold,i; 34 | for (pass = 1; pass < SIZE; ++pass) { 35 | for (i = 0; i < SIZE - 1; ++i) { 36 | if (c[i] > c[i + 1]) { 37 | hold = c[i]; 38 | c[i] = c[i + 1]; 39 | c[i + 1] = hold; 40 | 41 | hold = a[i]; 42 | a[i] = a[i + 1]; 43 | a[i + 1] = hold; 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /week/week3/ch3if_else: -------------------------------------------------------------------------------- 1 | // Fig. 2.13: fig02_13.c 2 | // Using if statements, relational 3 | // operators, and equality operators 4 | #include 5 | 6 | // function main begins program execution 7 | int main( void ) 8 | { 9 | printf( "Enter a grade, and I will tell you\n" ); 10 | printf( "the results: " ); 11 | 12 | int num1; // first number to be read from user 13 | //int num2; // second number to be read from user 14 | 15 | scanf( "%d", &num1); // read two integers 16 | 17 | if ( num1 >=90 ) { //如果if括弧內的結果為true ,就會執行if的大括弧內的內容 18 | //如果if括弧內的結果為false ,就跳過if的大括弧內的內容 19 | puts("A"); 20 | } 21 | else if (num1 >=80 ) { 22 | puts("B"); 23 | } // end if 24 | else if (num1 >=70 ) { 25 | puts("C"); 26 | } // end if 27 | else if (num1 >=60 ) { 28 | puts("D"); 29 | } // end if 30 | else { 31 | puts("F"); 32 | } // end if 33 | return 0; 34 | } // end function main 35 | -------------------------------------------------------------------------------- /1411131011/week2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | printf(" Enter three integers, and I will tell you\n"); 6 | printf("the sum, average, product, the largest and the smallest values: "); 7 | 8 | int a, b, c, largest = 0, smallest = 999; 9 | 10 | scanf("%d" "%d" "%d", &a, &b, &c ); 11 | 12 | if (a >= b) { 13 | if (a >= c) 14 | largest = a; 15 | else 16 | largest = b; 17 | } //end if 18 | else if (c > b) { 19 | largest = c; 20 | } // end if 21 | else { 22 | largest = b; 23 | } //end if 24 | 25 | if (a >= b) { 26 | smallest = b; 27 | } //end if 28 | if (b >= a) { 29 | smallest = a; 30 | } //end if 31 | if (c < smallest) { 32 | smallest = c; 33 | } //end if 34 | 35 | printf("Sum is %d\n", num1 + num2 + num3); 36 | printf("Average is %d\n",(num1+num2+num3)/3); 37 | printf( "Product is %d\n, num1*num2*num3 ); 38 | printf( "Smallest is %d\n" 39 | } 40 | -------------------------------------------------------------------------------- /week/week3/Nest_if_else: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // function main begins program execution 4 | int main( void ) 5 | { 6 | printf( "Enter a grade, and I will tell you\n" ); 7 | printf( "the results: " ); 8 | 9 | int num1; // first number to be read from user 10 | //int num2; // second number to be read from user 11 | 12 | scanf( "%d", &num1); // read two integers 13 | 14 | if ( num1 >=90 ) { //如果if括弧內的結果為true ,就會執行if的大括弧內的內容 15 | //如果if括弧內的結果為false ,就跳過if的大括弧內的內容 16 | puts("A"); 17 | } 18 | else { 19 | if (num1 >=80 ) { 20 | puts("B"); 21 | } // end if 22 | else { 23 | if (num1 >=70 ) { 24 | puts("C"); 25 | } // end if 26 | else { 27 | if (num1 >=60 ) { 28 | puts("D"); 29 | } 30 | else{ 31 | puts("F"); 32 | } 33 | } 34 | } 35 | } // end if 36 | // end if 37 | return 0; 38 | } // end function main 39 | -------------------------------------------------------------------------------- /1411131033/week16: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int upper(char str[]); 6 | int lower(char str[]); 7 | int num(char str[]); 8 | char str[] = "abcDEFG"; 9 | int (*f[3])(char*) = { upper, lower, num }; 10 | int i; 11 | int main(void) 12 | { 13 | printf("原始字串:%s\n", str); 14 | printf("英文小寫個數:%d\n", (*f[0])(str)); 15 | printf("英文大寫個數:%d\n", (*f[1])(str)); 16 | printf("數字個數:%d\n", (*f[2])(str)); 17 | 18 | } 19 | 20 | int upper(char str[]) 21 | { 22 | int a = 0; 23 | for (i = 0; i < 8; i++) 24 | { 25 | if (islower(str[i])!= 0) 26 | { 27 | a++; 28 | } 29 | } 30 | return a; 31 | } 32 | 33 | int lower(char str[]) 34 | { 35 | int b = 0; 36 | for (i = 0; i < 8; i++) 37 | { 38 | if (isupper(str[i]) != 0) 39 | { 40 | 41 | b++; 42 | } 43 | } 44 | return b; 45 | 46 | } 47 | 48 | int num(char str[]) 49 | { 50 | int c = 0; 51 | for (i = 0; i < 8; i++) 52 | { 53 | if (isdigit(str[i]) != 0) 54 | { 55 | 56 | c++; 57 | } 58 | } 59 | return c; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /1411031012/W5: -------------------------------------------------------------------------------- 1 | // Fig. 5.3: fig05_03.c 2 | // Creating and using a programmer-defined function. 3 | #include 4 | #include 5 | int facto(int); 6 | double expo(int); 7 | int power(int, int); 8 | 9 | int main(void) 10 | { 11 | int x; 12 | int num = 0, p = 0; 13 | for (x = 1; x <= 15; ++x) { 14 | printf("%d ", facto(x)); 15 | } 16 | printf("\nvalue of e is:%lf", expo(10)); 17 | printf("\n次方:%lf", power(2,y)); 18 | puts(""); 19 | } 20 | 21 | 22 | 23 | int facto(int y) 24 | { 25 | int result = 1, i; 26 | for (i = 1; i <= y; i++) 27 | result = result * i; 28 | return result; 29 | } 30 | 31 | double expo(int y) { 32 | int result = 1, i; 33 | double expo = 1.0; 34 | for (i = 1; i <= y; i++) { 35 | result = result * i; 36 | expo = expo + (1.0 / result); 37 | } 38 | return expo; 39 | } 40 | 41 | 42 | int power(int x, int y) { 43 | 44 | int result = 1; 45 | for (int i = 1; i <= y; i++) 46 | { 47 | result = result * i; 48 | power = pow(2, result); 49 | return power; 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /1411131045/陣列3.cpp: -------------------------------------------------------------------------------- 1 | // 陣列3.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。 2 | // 3 | 4 | #include 5 | void sub1(int n[], int size); 6 | #define SIZE 5 7 | int main(void) 8 | { 9 | int n[SIZE] = { 19, 3, 15, 7, 11 }, i, j; 10 | 11 | printf("%s%13s%17s\n", "Element", "Value", "Histogram"); 12 | sub1(n,SIZE); 13 | 14 | } 15 | void sub1(int n[], int size) 16 | { 17 | for (int i = 0; i < size; ++i) { 18 | printf("%7u%13d ", i, n[i]); 19 | 20 | for (int j = 1; j <= n[i]; ++j) { 21 | printf("%c", '*'); 22 | } 23 | 24 | puts(""); 25 | } 26 | } 27 | 28 | // 執行程式: Ctrl + F5 或 [偵錯] > [啟動但不偵錯] 功能表 29 | // 偵錯程式: F5 或 [偵錯] > [啟動偵錯] 功能表 30 | 31 | // 開始使用的提示: 32 | // 1. 使用 [方案總管] 視窗,新增/管理檔案 33 | // 2. 使用 [Team Explorer] 視窗,連線到原始檔控制 34 | // 3. 使用 [輸出] 視窗,參閱組建輸出與其他訊息 35 | // 4. 使用 [錯誤清單] 視窗,檢視錯誤 36 | // 5. 前往 [專案] > [新增項目],建立新的程式碼檔案,或是前往 [專案] > [新增現有項目],將現有程式碼檔案新增至專案 37 | // 6. 之後要再次開啟此專案時,請前往 [檔案] > [開啟] > [專案],然後選取 .sln 檔案 38 | -------------------------------------------------------------------------------- /1411131041/week3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | 5 | 6 | int main(void) 7 | { 8 | printf("Enter a grade, and I will tell you\n"); 9 | printf("the results: "); 10 | 11 | int num1; // first number to be read from user 12 | //int num2; // second number to be read from user 13 | 14 | scanf_s("%d", &num1); // read two integers 15 | 16 | if (num1 >= 90) { //如果if括弧內的結果為true ,就會執行if的大括弧內的內容 17 | //如果if括弧內的結果為false ,就跳過if的大括弧內的內容 18 | puts("A"); 19 | } 20 | else { 21 | if (num1 >= 80) { 22 | puts("B"); 23 | } // end if 24 | else { 25 | if (num1 >= 70) { 26 | puts("C"); 27 | } // end if 28 | else { 29 | if (num1 >= 60) { 30 | puts("D"); 31 | } // end if 32 | else { 33 | puts("F"); 34 | } // end if 35 | 36 | } 37 | } 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /1411131053/1/1/1/1.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 來源檔案 20 | 21 | 22 | -------------------------------------------------------------------------------- /1411131053/2/2/2/2.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 來源檔案 20 | 21 | 22 | --------------------------------------------------------------------------------