Giter Club home page Giter Club logo

candc-'s Introduction

candc-'s People

Contributors

roberthsu2003 avatar roberthsu2004 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

candc-'s Issues

計算bmi值,請使用物件導向的寫法

建立class BMI

  • 欄位->name,height,weight
  • 建立自訂的建構式
  • 建立實體方法 get_bmi()
  • 建立實體方法 status()
請輸入姓名:xxxx
請輸入身高:xxx
請輸入體重:xxx
xxxx的bmi是:xxx
xxx的體重:正常
截圖 2024-06-25 晚上9 55 17

作業_範本

請輸出剛才老師打的內容

#include <stdio.h>

int main(void) {
  printf("Hello C語言\n");
  printf("這是c語的第一節課\n");
  printf("這是一個線上真人課程\n");
  return 0;
}

作業3

請計算使用者的BMI

請輸入您的身高(公分):xxx
請輸入您的體重(公斤):xxx

您的BMI:xxxx

guess.cpp 猜數字有bug

老師好:
if(keyin >=1 && keyin <=99){
if(keyin == guess){
這邊的1&99應該改成min & max,
否則猜數字過程中猜的數字超出範圍的話不會顯示else區塊內容

練習1-BMI值計算

  • 提示 - 請輸入身高(公分):
  • 提示 - 請輸入體重(公斤):
  • 您的BMI:xxx.xxx

蕭佩倛

#include <stdio.h>

int main(void) {
  double Height,Weight,BMI;
  
  printf("請輸入身高(公分):");
  scanf("%lf", &Height);
  printf("請輸入體重(公斤):");
  scanf("%lf", &Weight);
  Height=Height/100;
  BMI=Weight/(Height*Height);
  printf("你的BMI:%.3lf\n",BMI);
  return 0;
}

c++ 1_3_5 作業2,請增加array_ascent的程式

#include <iostream>
using namespace std;

void print_array(int n[], int num) {
  for (int i = 0; i < num; i++) {
    cout << n[i] << " ";
  }
  cout << endl;
}

void array_descent(int arr[], int num) {
  for (int i = 0; i < (num - 1); i++) {
    for (int j = i + 1; j < num; j++) {
      //前面的 nums[i]
      //後面的 nums[j]
      //由大到小排序,前面小於後面的要對調
      if (arr[i] < arr[j]) {
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
      }
    }
  }
}

void array_ascent(int array[], int n) {
  //由小到大的排序
}

int main() {
  int n;
  cout << "請輸入排序的數量:";
  cin >> n;

  int nums[n];
  cout << "請一次輸入" << n << "個數值(數值和數值間要空隔):";
  for (int i = 0; i < n; i++) {
    cin >> nums[i];
  }

  cout << "排序前:\n";
  print_array(nums, n);

  //排序descent
  array_descent(nums, n);

  cout << "排序後:\n";
  print_array(nums, n);
}

x = [-b±√(b2-4ac)]/(2a)

#include <iostream>
#include <cmath>
using namespace std;

int main() {
  int x,a,b,c;
  int type;
  float result;
  float result2;
  float result3;
  cout << "Type: ax^2+by+c";
    cout << endl << "Input a: ";
  cin >> a;
    cout << endl << "Input b: ";
  cin >> b;
    cout << endl << "Input c: ";
  cin >> c;
  cout << "Calculation: " << "x = (-b+/-sqrt(pow(b, 2)-(4a*c))/2*a";
  if((pow(b, 2) - 4 * a * c) > 0) {
      type=2;
  }
  if((pow(b, 2) - 4 * a * c) == 0) {
      type=1;
  }
  if((pow(b, 2) - 4 * a * c) < 0) {
      type=0;
  }
  result=(-b+sqrt(pow(b, 2)-(4*a*c))/2*a);
  result2=(-b-sqrt(pow(b, 2)-(4*a*c))/2*a);
  result3=-b/2*a;
  if(type == 2) {
    cout << "\n There are two results: " << result << " and " << result2;
    return 0;
  }
  if(type == 1) {
    cout << "\n There is only one result: " << result3;
    return 0;
  }
  if(type == 0) {
    cout << "\n There are no results.";
    return 1;
  }
}

c4:計算BMI值

  • 請輸入身高(公分):
  • 請輸入體重(公斤):
  • 您的BMI:xxx.xxx
  • 您的體重:正常
截圖 2024-05-16 晚上9 31 33 截圖 2024-05-23 晚上8 31 56

1. 請將梯形面積的程式加入

#include <stdio.h>

int main(void) {
  printf("求梯型面積(上底+下底) * 高 / 2\n");
  printf("上底:2\n");
  printf("下底:3\n");
  printf("高:3\n");
  printf("面積:%.3lf\n",(2 + 3) * 3 / 2.0);
  printf("面積:%.3lf\n",(2 + 3) * (double)3 / 2);
  return 0;
}

使用lesson1_6,求出亂數值的最大值和最小值

輸出

請輸入元素數量:10
第1個元素:268
第2個元素:287
第3個元素:332
第4個元素:460
第5個元素:251
第6個元素:275
第7個元素:221
第8個元素:295
第9個元素:181
第10個元素:308
元素最大值是:460
元素最小值是:181

c++_1_3_5作業1

截圖 2024-01-03 晚上9 35 35
x = 1, y=1,2,3,4
x = 2, y=1,2,3,4
x = 3, y=1,2,3,4
x = 4, y=1,2,3,4
巢狀迴圈

int func2(int x, int y){
      xxxxxx;
     xxxxxxx;
    return xxxxx;
}

大樂透問題

擷取
老師好,之前有向您請問大樂透題目的問題
我已經理解紅框處的意義在於把已經選到的數字與最後一個數字交換位置,然後扣掉做最後一個位置取剩下下數字,就不會導致重複。但我想問的是為何可以直接寫lot[randIndex]=lot[maxIndex]就讓此兩索引位置的數字交換,而不用使用類似像是Swap的函數交換呢? 謝謝老師

練習4:while迴圈

請設計一個程式,讓使用者輸入數值,只有加總正偶數值,不加總正奇數值,如果輸入負數,結束程式。

  • 輸入:
    請輸入第1個數值:456
    請輸入第2個數值:455
    請輸入第3個數值:123
    請輸入第4個數值:-1

  • 輸出:
    所有輸入的正偶數的加總是:xxxxxxx

c++ 1_3_5_作業上,請使用macro,完成以下的程式

#include <iostream>
#define 請依照下列程式碼!定義出正確的macro
int main() {
	int s, result;
	cout << "請輸入數字:";
	cin >> s;
	result = SQUARE(s);
	cout << s << "的平方為:" << result << endl;
        result = SQUARE(s+1);
       cout << s+1 << "的平方為:" << result << endl;

請依照lesson2_2的內容,建立由大到小的排序

#include <iostream>
#include <time.h>
using namespace std;

int main() {
	srandom(time(NULL));
	int min = 100, max = 500;
	int nums;
	cout << "請輸入元素數量:";
	cin >> nums;
	int array[nums];
	//輸入
	for (int i = 0; i < nums; i++) {
		array[i] = random() % (max - min + 1) + min;
	}
	
	cout << "排序前" << endl;
	for(int i=0; i<nums; i++){
		cout << array[i] << " ";
	}
	cout << endl;

	//泡沫排序
	for(int i=0; i < nums-1; i++){
		for(int j=i+1; j<nums; j++){
			if (array[i] > array[j]){
				//由小到大,對調
				int temp = array[i];
				array[i] = array[j];
				array[j] = temp;
			}
		}
	}

	cout << "排序後" << endl;
	for(int i=0; i<nums; i++){
		cout << array[i] << " ";
	}
	cout << endl;
}

解題

1.寫一程式,完成下列計算
A = ⌜1 2⌝、B =⌜1 2 1⌝ ,求3A * B²
| 2 1 | ⌞2 1 2⌟
| 1 2 |
⌞2 1⌟

2.寫一程式,以structure方式輸入下列3位同學成績,並計算及列印每科平均成績及總成績最高分同學名子
John | 90 | 92 | 94
Eason | 80 | 96 | 98
Ian | 88 | 94 | 96
3.寫一程式,以linked list(動態記憶體配置)方式,輸入下列4位同學成績,並按成績高低排序印出成績
學號 | 1 | 2 | 3 | 4
成績 | 60 | 90 | 70 | 80
4.寫一程式,將字串”wwwcsietkuedutw”分別儲存成純文字檔”input.txt”及二進位檔”input.bin”

練習2:

請使用者輸入一個任意數,程式會顯示此數的平方值及立方值(請使用複合指定運算子*=)

輸入:
請輸入任意數:5

輸出:
5的平方是25
5的立方是125

作業2

利用2層for迴圈列印「井」字,將其排列成直角三角形

#
##
###
####
#####

作業4

請計算使用者的BMI

請輸入您的身高(公分):xxx
請輸入您的體重(公斤):xxx

您的BMI:xxxx
您的體重:xxxx

同學有問題!看哪位同學可以幫忙

老師您好
我昨天練習求出亂數值的最大值和最小值,但結果error,不清楚哪裡錯誤

#include <iostream>
#include <time.h>
using namespace std;

int main() {  
  srandom(time(NULL));
  int min =1;
  int max =99;
  int nums;
    cout << "請輸入元素數量:";
    cin >> nums;
    int n[nums];
    //輸入
    for (int i = 0; i < nums; i++) {
      n[i] = random() % (max - min + 1) + min;
    }

    //輸出
  int max_value = n[0];
  int min_value = n[0];
  for (int i = 0; i < nums; i++) {
      cout << "第" << i + 1 << "個元素:";
      cout << n[i] << endl;
      if (n[i] > max_value) {
        max_value = n[i];
      }
      if (n[i] < min_value) {
        min_value = n[i];
     }
    cout << "最大值為:" << max_value << endl;
    cout << "最小值為:" << min_value << endl;
   
}

新手求解

未命名

大家好, 剛在學寫程式而已
想嘗試用迴圈計算這個
但是"参天花費"一直都是10
請問是哪裡出了錯....

要求使用者輸入前幾名的學生

輸入

請輸入想要班上前幾名的學生:5

輸出

班上前5名的學生是:
xxxxx xx xx xx xxx
xxxxx xx xx xx xxx
xxxxx xx xx xx xxx
xxxxx xx xx xx xxx
xxxxx xx xx xx xxx

依據以下程式:

#include <iostream>
using namespace std;

typedef struct student {
  string name;
  int chinese;
  int english;
  int math;
} Student;

void random_student(Student s[], int elems) {
  int min = 50;
  int max = 100;
  for (int i = 0; i < elems; i++) {
    s[i].name = "第" + to_string(i + 1) + "號學生";
    s[i].chinese = random() % (max - min + 1) + min;
    s[i].english = random() % (max - min + 1) + min;
    s[i].math = random() % (max - min + 1) + min;
    cout << s[i].name << " ";
    cout << s[i].chinese << " ";
    cout << s[i].english << " ";
    cout << s[i].math << " ";
    cout << s[i].chinese + s[i].english + s[i].math << endl;
  }
}

int main() {
  srandom(time(NULL));
  int nums;
  cout << "請輸入學生數量:";
  cin >> nums;
  Student students[nums];
  random_student(students, nums);

  
}

依據lesson5_2,請多輸出一行

姓名:徐國堂
身高:183cm
體重:81kg
BMI:24.187
您的狀況:過重
您必需最少減重xx公斤,才可以至標準,或加重多少,才可以至標準

老師您好:我有以下問題想請教您

  1. 在二分搜尋法解題中有出現 for(;;) ,想請教在這邊的用意是為什麼呢?謝謝

  2. 想請問在C語言中,LinkedList 的反轉問題 (在網路上搜尋過很多解法,但都看得我邏輯好亂QQ)

再麻煩老師回覆,謝謝 :)

請將結構改為class

#include <iostream>
#include <time.h>
using namespace std;
typedef struct student {
  string name;
  int chinese;
  int english;
  int math;
  int total;
} Student;

void create_student(Student *array, int m) {
  srandom(time(NULL));
  int min = 50;
  int max = 100;
  for (int i = 0; i < m; i++) {
    array[i].name = "stu" + to_string(i + 1);
    array[i].chinese = random() % (max - min + 1) + min;
    array[i].english = random() % (max - min + 1) + min;
    array[i].math = random() % (max - min + 1) + min;
    array[i].total = array[i].chinese + array[i].english + array[i].math;
  }
}

void sorted(Student *array, int m){
	// 使用泡沫排序法依據總分由高而低排序
	for (int i = 0; i < m - 1; i++) {
		for (int j = 0; j < m - i - 1; j++) {
			if (array[j].total < array[j + 1].total) {
				Student temp = array[j];
				array[j] = array[j + 1];
				array[j + 1] = temp;
			}
		}
	}
}

int main() {
  int nums;
  cout << "請輸入學生數量:";
  cin >> nums;
  Student students[nums];
  create_student(students, nums);
	sorted(students,nums);  

  for (int i = 0; i < nums; i++) {
    cout << "name:" << students[i].name << endl;
    cout << "總分:" << students[i].total << endl;
    cout << "排名:" << i + 1 << endl;
    cout << "=========" << endl;
  }
}

練習3:BMI

截圖 2024-02-19 晚上9 20 22 截圖 2024-02-19 晚上9 20 35

輸入:

  • 請輸入身高(公分):xxx
  • 請輸入體重(公斤):xxx

輸出:

  • 您的BMI:xxx
  • 您的體重:過重

星期日_作業1

請計算3角型的面績

請輸入三角型的底和高(底,高):xxx,xxxx

==========================
三角型的底是:xxx
三角型的高是:xxx
三角型的面積是:xxxxxx

作業2:

讓使用者輸入三個任意數,程式會顯示三數中的最小數。

c2:計算BMI值

  • 請輸入身高(公分):
  • 請輸入體重(公斤):
  • 您的BMI:xxx.xxx
截圖 2024-05-16 晚上9 31 33

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.