广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 3440 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
Reeve
个人头像
个人文章 个人相簿 个人日记 个人地图
初露锋芒
级别: 初露锋芒 该用户目前不上站
推文 x0 鲜花 x19
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[C/C++] 有人会做这两道题吗?
Question 1:
Write a program that initializes the 10 student scores in an array to be zero. It will ask the user to input the scores available. Note that this array of size 10 could be filled up in full or partially. A menu will be displayed afterwards, allowing the user to choose to perform one of the following functions:
1. Count the number of non-zero elements (which means the actual size of the array);
2. Find the maximum and minimum scores in the array through its reference parameters;
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);
4. Find the second largest score in the array;
5. Check whether a particular score is found within the f ..

访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容




献花 x0 回到顶端 [楼 主] From:澳门 特别行政区 | 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.015707 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言