# 程式設計實習
## 20230913課堂作業
### 第一題練習題
題目:請撰寫一個程式,宣告變數a=10 b=101.7 c='c!

```
#include<iostream>
using namespace std;
int main()
{
int a=10;
float b=107.3;
char c='c';
}
```
### 第二題練習題
題目:請輸入字母大寫:A,A的小寫是a
```
#include<iostream>
using namespace std;
int main()
{
char gay1,gay2;
cout<<"請輸入大寫字母";
cin>>gay1;
gay2=gay1+32;
cout<< gay1 <<"的小寫是"<< gay2 <<endl;
}
![Uploading file..._dhzr6nm7s]()
```

### 第三題練習題
```
#include<iostream>
using namespace std;
int main()
{
int gay1= 60;
int gay2= 80;
int gaybox;
gaybox=gay1;
gay1=gay2;
gay2=gaybox;
cout<< gay1<<" "<<gay2<< endl;
}
```

### 第四題練習題
題目:算圓面積
```
#include<iostream>
using namespace std;
int main()
{
int r;
cout<<"請輸入圓半徑";
cin>>r;
const double Pi=3.1415926;
double area;
area=r*r*Pi;
cout<<"圓的面積是"<<area;
}
```

### 心得
我自己在c++上還不太順手,因為有太多東西要去打但我並不知道那個是幹嘛的相對pyhon目前對我來說就沒有這個問題,但我會盡力把這兩個都學好,我發現自己的程式邏輯還可以,但有些語法的功能我還不能駕輕就熟,這周的作業我弄得有點吃力因為不能在老師講解時就了解該語法的功用,,我希望未來我能夠熟悉C++
## 20230920 課堂作業
### 第一題練習
題目:匯率換算
```
#define USD 0.031
#define JPS 4.62
using namespace std;
int main()
{
int money;
cout<<"請輸入金額";
cin>>money;
cout<<"可兌換"<<money*USD<<"美元"<<endl;
cout<<"或兌換"<<money*JPS<<"日幣"<<endl;
}
```

### 第二題練習
題目:硬幣轉換
```
//程式設計實習 資訊一甲 翁叡毅17號
//230920
#include<iostream>
using namespace std;
int main()
{
int coin,coin10,coin5,coin1;
cout<<"請輸入兌幣金額";
cin>>coin;
coin10=coin/10;
coin5=coin%10/5;
coin1=coin%10%5;
cout<<"共可兌換"<<coin10<<"個10元"<<coin5<<"個5元"<<coin1<<"個1元";
}
```

### 練習3
```
//程式設計實習 資訊一甲 翁叡毅17號
//230920
#include<iostream>
using namespace std;
int main()
{
float C,F;
cout<<"請輸入華氏溫度";
cin>>F;
C=(F-32)*5/9;
cout<<"攝氏溫度為"<<C;
}
```

### 練習4
`//程式設計實習 資訊一甲 翁叡毅17號
//230920
#include<iostream>
using namespace std;
int main()
{
int coin,coin10,coin5,coin1,coin50;
cout<<"請輸入兌幣金額";
cin>>coin;
coin50=coin/50;
coin10=coin%50/10;
coin5=coin%50%10/5;
coin1=coin%50%10%5;
cout<<"共可兌換"<<coin50<<"個50元"<<coin10<<"個10元"<<coin5<<"個5元"<<coin1<<"個1元";
}
`

### 心得:
這次學了用define來定義固定值並且我解決了不熟悉的問題,我已經能將之前的所學運用到這次的作業,比如匯率換算和溫度換算我就用到了浮點數,期待學到更多的語法,以讓我做利用。
## 20230927程式設計實習作業
### 練習1:
```
include<iostream>
using namespace std;
///程式設計實習 230927
///資訊一甲翁叡毅
int main()
{
int choise;
cout<<"發生船難,你選擇留下什麼?"<<endl<<"選擇(1)留下老人和孕婦 "<<endl<<"選擇(2)留下老人和嬰兒"<<endl<<"選擇(3)留下老人和金銀珠寶"<<endl<<"選擇(4)留下孕婦和嬰兒"<<endl<<"選擇(5)留下孕婦和金銀珠寶"<<endl<<"選擇(6)留下嬰兒和金銀珠寶";
cin>> choise;
if (choise==1)
cout<<"(1)你的情感很細膩,善於觀察細節。在感情中,相比於戀人的甜言蜜語,你更在乎對方實際的行動。";
if (choise==2)
cout<<"在感情中,你不僅洞察力超好,第六感也很強,越是親近的人這種直覺越敏銳,所以另一半對你很難有所隱藏,因為你可以憑借著蛛絲馬跡得到你想要知道的消息";
if (choise=3)
cout<<"你是個典型的顏控,在擇偶時很注重另一半的外表和身高。";
if (choise=4)
cout<<"面對感情你很承盾,一方面你很感性,渴望浪漫熱烈的愛情;另一方面你又很理性,明白現實的殘酷和金錢的重要性";
if (choise=5)
cout<<"在感情方面你很挑剔,所以很難遇到心動的對象。不過在戀愛時你卻很專一,一旦喜歡上某個人,你就會全心全意的對他好,所以和你談戀愛是一件很幸福的事。";
if (choise=6)
cout<<"在感情中你很缺乏安全感,有時候會忍不住通過試探或考驗的方式去確認對方是否愛你。";
else
cout<<"亂輸入,活該一輩子舔狗命!!!";
}
```

### 練習2:算象限
```
#include<iostream>
using namespace std;
///程式設計實習 230927
///資訊一甲翁叡毅
int main()
{
int X;
int Y;
cout<<"請輸入X軸";
cin>>X;
cout<<"請輸入Y軸";
cin>>Y;
if(X>0 && Y>0)
cout<<"("<<X<<","<<Y<<")"<<"在第一象限";
else if(X<0 && Y>0)
cout<<"("<<X<<","<<Y<<")"<<"在第二象限";
else if(X<0 && Y<0)
cout<<"("<<X<<","<<Y<<")"<<"在第三象限";
else if(X>0 && Y<0)
cout<<"("<<X<<","<<Y<<")"<<"在第四象限";
}
```

### 練習3:counting star(正三角)
```
#include<iostream>
using namespace std;
///程式設計實習 230927
///資訊一甲翁叡毅
int main()
{
int k;
cout <<"請輸入層數";
cin >> k;
for(int f=1;f<=k; f++){
for(int j=1; j<=f;j++){
cout<<"*";
}
cout<< endl;
}
}
```

### 練習4:生肖
```
#include<iostream>
using namespace std;
///程式設計實習 230927
///資訊一甲翁叡毅
int main()
{
int y;
cout<<"請輸入民國年";
cin>>y;
if (y%12==1)
cout<<"你屬勞贖";
else if (y%12==2)
cout<<"你屬牛";
else if (y%12==3)
cout<<"你屬虎";
else if (y%12==4)
cout<<"你屬兔";
else if (y%12==5)
cout<<"你屬龍";
else if (y%12==6)
cout<<"你屬蛇";
else if (y%12==7)
cout<<"你屬馬";
else if (y%12==8)
cout<<"你屬羊";
else if (y%12==9)
cout<<"你屬猴";
else if (y%12==10)
cout<<"你屬雞";
else if (y%12==11)
cout<<"你屬狗";
else if (y%12==0)
cout<<"你屬豬";
else
cout<<"你屬貓";
}
```

### 練習5:平閏年
```
#include<iostream>
using namespace std;
///程式設計實習 230927
///資訊一甲翁叡毅
int main()
{
int y;
cout<<"請輸入年分";
cin>>y;
if(y%4==0)
cout<<"閏年";
else
cout<<"平年";
}
```

### 心得:
這周用了if else,這是個很好用的語法,
透過這個可以拿來設很多東西,但我還不太熟練迴圈的語法,
希望我下周在寫迴圈時能更加精熟,因為迴圈和if else一樣是很重要的語法。
## 20231004 課堂作業
### 練習1 題目算電費:
```
#include<iostream>
using namespace std;
///程式設計實習 230927
///資訊一甲翁叡毅
int main()
{
int T;
cout<<"請輸入用電度數:";
float money;
cin>>T;
if(T<120){
money+=T*1.63;
}
else if(T>=120&&T<330){
money+=120*1.63+(T-120)*2.38;
}
else if(T>=330&&T<500){
money+=120*1.63+210*2.38+(T-330)*3.52;
}
else if(T>=500&&T<700){
money+=120*1.63+210*2.38+170*3.52+(T-500)*4.80;
}
else if(T>=700&&T<1000){
money+=120*1.63+210*2.38+170*3.52+200*4.80+(T-700)*5.83;
}
else {
money+=120*1.63+210*2.38+170*3.52+200*4.80+300*5.83+(T-1000)*7.69;
}
cout<<"電費為:"<<money<<"元"<<endl;
}
```

### 練習2 題目算總分
```
#include<iostream>
///程式設計實習 230927
///資訊一甲翁叡毅
using namespace std;
int main()
{
cout<<"請輸入各科成績 "<<endl;
int a,count = 0;
do{
cin>>a;
count+=a;
} while(a != -1);
count+=1;
cout<<"總分是"<<count<<endl;
}
```

### 練習3 判斷奇偶
```
#include<iostream>
///程式設計實習 230927
///資訊一甲翁叡毅
using namespace std;
int main()
{
int a;
cin>>a;
if(a%2 == 1)
cout<<"奇數"<<endl;
else
cout<<"偶數"<<endl;
}
```

### 練習4 題目:被3整除數學問題
```
#include<iostream>
///程式設計實習 230927
///資訊一甲翁叡毅
using namespace std;
int main()
{
int x;
x = 1;
while(x == 1){
cout<<"請輸入一個整數"<<endl;
int a,b = 3,count = 0;
cin>>a;
x = 0;
b = 0;
while(b<=a){
count+=b;
b+=3;
}
cout<<count<<endl;
cout<<"是否再算一次"<<endl;
cin>>x;
}
}
```

### 練習5 題目:大大大優惠
```
#include<iostream>
///程式設計實習 230927
///資訊一甲翁叡毅
using namespace std;
int main()
{
cout<<"購買商品定價為"<<endl;
int a,b,c;
cin>>a;
cout<<"是會員打1,不是會員打2"<<endl;
cin>>b;
if(b == 1){
cout<<"鑽石會員請扣1,白金會員請扣2,普通會員請扣3"<<endl;
cin>>c;
if(c == 1){
cout<<"商品的價格為"<<a*0.7<<endl;
}
else if(c == 2){
cout<<"商品金錢的價格"<<a*0.8<<endl;
}
else{
cout<<"商品的價格為"<<a*0.9<<endl;
}
}
else{
cout<<"商品的價格為"<<a<<endl;
}
}
```

### 題目6 班平均
```
#include<iostream>
///程式設計實習 230927
///資訊一甲翁叡毅
using namespace std;
int main()
{
cout<<"輸入全班人數:";
int a,count = 0,p = 0,f= 0;
cin>>a;
cout<<"輸入同學成績"<<endl;
for(int i = 0;i<a;i++){
int b;
cin>>b;
count+=b;
if(b>=60){
p+=1;
}
else{
f+=1;
}
}
count/=a;
cout<<"全班平均"<<count<<endl;
cout<<"及格人數"<<p<<endl;
cout<<"該重修的小孩數量"<<f<<endl;
}
```

### 練習7 題目:絕對值
```
#include<iostream>
///程式設計實習 230927
///資訊一甲翁叡毅
using namespace std;
int main()
{
int n;
cout<<"請輸入數值:>";
cin>>n;
int d=n*-1;
if(n<0){
cout<<"絕對值是"<<d;
}
else{
cout<<"絕對值是"<<n;
}
}
```

### 練習8 題目:雞兔
```
#include<iostream>
///程式設計實習 230927
///資訊一甲翁叡毅
using namespace std;
int main()
{
int a,b;
cout<<"有幾隻動物";
cin>>a;
cout<<"有幾隻腳";
cin>>b;
int c = b-2*a;
int d = c/2;
int e = a-d;
cout<<"兔子有: "<<d<<"隻"<<"雞有"<<e<<"隻";
}
```

## 20231101 程式作業
### 題目1:查詢語音費率函式
```
#include <iostream>
using namespace std;
void bill(int a){
switch(a){
case 196:
cout<<"語音費率為0.0896元";
break;
case 396:
cout<<"語音費率為0.0782";
break;
case 796:
cout<<"語音費率為0.0696";
break;
default:
cout<<"敢亂打你給我試試看";
}
}
int main()
{
int a;
cout<<"請輸入要查詢的方案(196 396 796):";
cin>>a;
bill(a);
}
```

### 題目2猜數字:

```
//程式設計實習 資訊一甲 17號 翁叡毅
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
int b(int a,int n){
if(a == n){
cout<<"猜對了!好耶"<<endl;
}
else if(a<n){
cout<<"猜錯了再大一點"<<endl;
}
else{
cout<<"猜錯了再小一點"<<endl;
}
}
int main(){
srand(time(0));
int n = (rand()%10)+1;
cout<<"猜猜看數字是多少?(1~10) : ";
int a;
do{
cin>>a;
b(a,n);
}while(a!=n);
}
```
### 題目3判斷三角形
```
//程式設計實習 資訊一甲 17號 翁叡毅
#include<iostream>
using namespace std;
int x(int a,int b,int c){
if(a+b<=c){
cout<<a<<"."<<b<<"."<<c<<"不可組成三角形"<<endl;
}
else if(c+a<=b){
cout<<a<<"."<<b<<"."<<c<<"不可組成三角形"<<endl;
}
else if(c+b<=a){
cout<<a<<"."<<b<<"."<<c<<"不可組成三角形"<<endl;
}
else{
cout<<a<<"."<<b<<"."<<c<<"可組成三角形"<<endl;
}
}
int main(){
cout<<"請輸入三角形的三個邊長:";
int a,b,c;
cin>>a>>b>>c;
x(a,b,c);
}
```

### 題目4:階層
```
#include <iostream>
//程式設計實習 資訊一甲 17號 翁叡毅
#include<iostream>
using namespace std;
int x(int a){
if(a == 1){
return 1;
}
return a*x(a-1);
}
int main(){
cout<<"請輸入一個正整數: ";
int aa;
cin>>aa;
cout<<"階層"<<aa<<"為"<<x(aa)<<endl;
}
```

## 程式實習學習歷程
### 文文的求婚


### 經濟大恐慌
說明:第一天毅叡會買一顆饅頭,一顆一塊,天數每過一天,饅頭購買數和價格都各加1,求第n天毅叡要花錢買饅頭
```
#include<bits/stdc++.h>
using namespace std;
int main()
{
int d=0,e=0;
cin>>d;
for(int i=1;i<=d;i++){
e+=pow(i,2);
}
cout << e;
}`

```

### 神奇寶貝進化
說明:在 Pokémon Go 遊戲中,獨角蟲 (Weedle) 是滿地爬的常見寶可夢。儘管稀有性不足,但是因為它只要 12 顆糖果就可以進化,所以常常被玩家大量補捉並進化,以賺取每次進化所得到的 500 XP 經驗值。
在遊戲中,每補獲一隻獨角蟲可以得到 3 顆糖果,每傳送一隻獨角蟲或是它所進化成的鐵殼蛹 (Kakuna) 給教授可以得到 1 顆糖果,每完成一隻獨角蟲的進化也可以得到一顆糖果。
給你文文目前所擁有的糖果及獨角蟲數量,(假設文文已經把所有的鐵殼蛹或由它再進化而成的大針蜂 (Beedrill)傳送給教授以換取糖果了,而且他會留下足夠的獨角蟲以儘可能進行最多的進化),請你幫他計算一下他現在可以完成幾隻獨角蟲的
```
#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"請輸入蟲數";
cin>>a;
int b;
cout<<"請輸入唐數";
cin>>b;
int c=0;
a*=3;
b+=a;
c=b/12;
cout<<"總共可進化"<<c<<"隻";
```

# 112物件導向實習
## 2024/2/21
### 你的名字
```
// See https://aka.ms/new-console-template for more information
Console.Write("請輸入你的名字");
string name = Console.ReadLine();
Console.WriteLine($"Good Day!{name}");
```

### 提款G
```
Console.Write("請輸入名稱:");
string? n = Console.ReadLine();
Console.Write("請輸入提款金額:");
int m = Convert.ToInt32(Console.ReadLine());
Console.WriteLine($"Hi {n}, 提款金額:{m:C0}");
```
