廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 2762 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
110075
數位造型
個人文章 個人相簿 個人日記 個人地圖
路人甲
級別: 路人甲 該用戶目前不上站
推文 x0 鮮花 x1
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[C/C++][求助] 這題真的好難...高手幫幫忙吧
請使用物件的方式撰寫一個程式,建立一個student類別,此類別包含了math、Eng、windows三個資料成員,請建立三個成員函數第一個將數學成績開根號後乘以 ..

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



獻花 x0 回到頂端 [樓 主] From:臺灣中華 | Posted:2008-04-13 19:58 |
DihKuh 手機
個人文章 個人相簿 個人日記 個人地圖
路人甲
級別: 路人甲 該用戶目前不上站
推文 x0 鮮花 x0
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

複製程式
 
#include <iostream>
#include <stdlib.h>
#include <math.h>

using namespace std;

class student
{
    private:
        int math,Eng,windows,windows1;
        float math1,Eng1;
    public:
        void student::score();
        void student::PrintTitle();   
        void student::Print();
        void student::input();
};    

void student::input()
{
    printf("math分數:");
    cin>>math;
    printf("Eng分數:");
    cin>>Eng;
    printf("windows分數:");
    cin>>windows;
}

void student::score()
{
   float x;
   x=math;
    math1=sqrt(x)*10;
    
    if (math1>100){math1=100;}
    Eng1=((float)Eng-50)*4/5+60;
    windows1=windows+20;
    if (windows1>100){windows1=100;}
}
    
void student::PrintTitle()   
{    
     printf("\n\n%s%12s%9s%10s\n","科目","math","Eng","windows");
     for (int k=0;k<(16+9+10);k++) printf("=");
     printf("\n");     
}

void student::Print()
{ 
    printf("線性調分前  ");
    printf("%4d %8d %9d\n",math,Eng,windows);
    printf("線性調分後  ");
    printf("%3.1f %8.1f %9d\n",math1,Eng1,windows1);
}    



int main(int argc, char *argv[])
{
  
  student John;
  student Mary;
  student Peter;
  
  cout<<"輸入John的成績\n";
  John.input();
  cout<<"輸入Mary的成績\n";
  Mary.input();
  cout<<"輸入Peter的成績\n";
  Peter.input();
  
  John.score();
  Mary.score();
  Peter.score();
  
  John.PrintTitle();
  cout<<"John的成績\n";
  John.Print();
  cout<<"Mary的成績\n";
  Mary.Print();
  cout<<"Peter的成績\n";
  Peter.Print();
  printf("\n"); 
  system("PAUSE");       
  return 0;
}


[ 此文章被DihKuh在2008-04-19 11:25重新編輯 ]


獻花 x0 回到頂端 [1 樓] From:臺灣 | Posted:2008-04-16 13:31 |

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