加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 4280 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   

頭像
個人文章 個人相簿 個人日記 個人地圖
路人甲
級別: *
推文 x 鮮花 x
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[C/C++] 有人會做這兩道題嗎?

訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容



獻花 x0 回到頂端 [樓 主] | Posted:2005-12-06 22:41 |
Reeve
個人頭像
個人文章 個人相簿 個人日記 個人地圖
初露鋒芒
級別: 初露鋒芒 該用戶目前不上站
推文 x0 鮮花 x19
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

is here anyone know how to do these questions
i need your help, thank you


獻花 x0 回到頂端 [1 樓] From:香港特別行政區 | Posted:2005-12-07 13:12 |
唐老鴨
個人頭像
個人文章 個人相簿 個人日記 個人地圖
初露鋒芒
級別: 初露鋒芒 該用戶目前不上站
推文 x1 鮮花 x230
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

下面是引用Reeve於2005-12-7 13:12發表的 :
is here anyone know how to do these questions
i need your help, thank you

can you at least post your program codes of two questions before asking for help 表情


沒東西可以抓
獻花 x1 回到頂端 [2 樓] From:美國 | Posted:2005-12-07 14:00 |
gohere
數位造型
個人文章 個人相簿 個人日記 個人地圖
小人物
級別: 小人物 該用戶目前不上站
推文 x0 鮮花 x12
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

這個應該是學校的程式作業吧
同唐老鴨說的,總不能重頭到尾全寫出來吧
雖然作業交差,可是自己學到的少之又少呢


獻花 x1 回到頂端 [3 樓] From:台灣中華電信 | Posted:2005-12-08 20:57 |
和煦微風 手機 會員卡 葫蘆墩家族
個人文章 個人相簿 個人日記 個人地圖
特殊貢獻獎
知名人士
級別: 知名人士 該用戶目前不上站
推文 x19 鮮花 x253
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

同感+1....
程式就是要自己寫過才會有經驗... 表情
剛開始一定都會很辛苦的....
像我們每次拿到作業...
就開始要構思到底要怎麼寫...
那是一個很痛苦的過程... 表情
雖然有時候根本寫不出來...
或是寫完以後連compile都不能過....
但是老師總是說...
就算寫不出來...交個屍體也好...
這樣他才知道哪邊我們不會.... 表情 表情 表情

而且...當每完成一個程式的時候...
那種高興的感覺是無法形容的...
所以建議樓主還是先寫出一些...
再PO上來跟大家討論吧~ 表情


獻花 x1 回到頂端 [4 樓] From:台灣教育部 | Posted:2005-12-08 21:16 |
Reeve
個人頭像
個人文章 個人相簿 個人日記 個人地圖
初露鋒芒
級別: 初露鋒芒 該用戶目前不上站
推文 x0 鮮花 x19
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

下面是引用和煦微風於2005-12-8 21:16發表的 :
同感+1....
程式就是要自己寫過才會有經驗... 表情
剛開始一定都會很辛苦的....
像我們每次拿到作業...
就開始要構思到底要怎麼寫...
.......

第一題,未完善

//Question1
#include <iostream.h>

int countSize(const float scores[]){ //to count how many soures what he/she input function
    for (int i = 0; i < 10; i ++){
if (scores == 0)
              break;
    }
    return i;
}

void getExtremes(float& min, float& max, const float scores[], int actualSize){ //get the maximum and the minimum scores
    min = scores[0];
    max = scores[0]; //set the maximum and the minimum scoures to the frist input
    for (int i = 0; i < actualSize; i ++){
              if (scores > max)   //get the maximum scoure
              max = scores;
       
        else {
              if (scores < min)     //get the minimum scoure
              min = scores; }
    }
}

float firstMin(const float scores[], int n){     //find the first minimum score function
    float min = scores[0];
    for (int i = 0; i < n; i ++){
        if (scores < min) {
              min = scores; }
    }
    return min;
}

float secondMax(const float scores[], int actualSize){     //find the secound maximum score function
    float max, SecondMax;
    max = SecondMax;
    SecondMax = scores[0];
    for (int i = 0; i < actualSize; i ++){
        if (scores > max){
              SecondMax = max;
              max = scores;     }
    }
    return SecondMax;
}

bool find(const float scores[], int n, float particular){ //find the terget score function
    for (int i = 0; i < n; i ++){
        if (scores == particular)
              return 1;
    }
    return 0;
}
void shift(float scores[], int n){ //shift the score to cover the space function
    for (int i = n; i <= 9; i ++){
        scores = scores[i+1];
    }
    scores[9] = 0;
}

bool remove(float scores[], int n, float target){ //remove the terget score function

    for (int i = 0; i < n; i ++){

        if (scores == target)
              shift(scores, i);

    }
    return 0;
}



void display(const float scores[]){ //display the array of scores fuction
    for (int i = 0; i < 10; i ++)
        cout << " {" << scores << "}";
    cout << endl;
}

int main(){
    float a[10];
    int i=0;
    int n;
    float min, max, particular;
    int choice;
    do {
    cout <<"Please Enter The Students' Scores : "; //input the students' scores
        cin >> a; //get the value
    }
    while (a[i++]!=0 && i < 10) ;

    cout <<"1.     Count the number of non-zero elements (which means the actual size of the array); "<<endl; //the menu
    cout <<"2.     Find the maximum and minimum scores in the array through its reference parameters;"<<endl;
    cout <<"3.     Find the minimum element among the first n elements (you should ask the user to specify the value for n first, and n should be less than or equal to the actual size of the array);"<<endl;
    cout <<"4.     Find the second largest score in the array;"<<endl;
    cout <<"5.     Check whether a particular score is found within the first n element in the array;"<<endl;
    cout <<"6.     Remove a targeted element from the first n elements in the array;"<<endl;
    cout <<"7.     Print the array of scores."<<endl;
    cin >> choice;
    switch (choice){
    case 1:
        cout <<"The number of non-zero elements: "<< countSize(a)<<endl; //count the elements
        cout <<"Please Enter The Students' Scores : "; //input the students' scores
        cin >> a; //get the value
        break;
    case 2:
        getExtremes(min,max,a,countSize(a)); //link the function
        cout <<"The maximum score in the array is: "<< max<<endl; //output the maximum
        cout <<"The minimum score in the array is: "<< min<<endl; //output the minimum
        break;
    case 3:
        cout <<"Please enter the n what n elements that you want to be counted: "<<endl; //set the n elements to be counted
        cin >> n; //get the value
        if ((n<=10)&&(n>0))     { //make sure 0<n<=10
              cout << "The minimum among the first "<<n<<" elemnts is: "<<firstMin(a, n)<<endl;} //output the answer
              else
                  cout <<"Please Enter an Possible Number!!"<<endl; //not allow input incorrect value
        break;
    case 4:
        cout <<"The second largest score in the array is: "<<secondMax(a, countSize(a))<<endl; //output the answer
        break;
    case 5:
        cout <<"Please enter the n what n elements that you want to be counted: "<<endl; //set the n elements to be counted
        cin >> n;
        if ((n<=10)&&(n>0))     { //make sure 0<n<=10
              cout << "Which particular score do you want to find? "; //ask to set the particular score
              cin >>particular; //get the value
              if (find(a, n, particular)) //if the function is true
              {
                  cout <<"Yes, I can find it. It is "<<particular<<endl; //to answer user we can find the value
              }
             
              else {
              cout <<"No, I couldn't find the particular scorce."<<endl; //to answer user we can't find it

              }    
   
        }
              else
                  cout <<"Please Enter an Possible Number!!"<<endl; //not allow to input a incorrect value


        break;
    case 6:


        break;
    case 7:
        cout<<"The array of scores is : ";
   
        break;
    default:
        cout <<"Please Enter an Possible Number!!"<<endl;
        display(a);
        break;
        }



    return 0;
}


獻花 x0 回到頂端 [5 樓] From:澳門 特別行政區 | Posted:2005-12-09 22:01 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.020008 second(s),query:16 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言