广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 2776 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为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.010956 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言