?? h1.h
字號:
/*給huige1.txt中寫入:"MicrosoftWindowsXP[版本5.1.2600] 2006".再將其中的內(nèi)容復制到huige2.txt中,定義一個字符數(shù)組ch[100],和一個long型 變量num,將huige1.txt中的字符和整型得到并輸出*/
#include<fstream.h>
#include<iostream.h>
void main()
{fstream s; char c,ch[100];long num;
fstream x;
s.open("d:\\huige1.txt",ios::out);
s<<"MicrosoftWindowsXP[版本5.1.2600] ";
s<<2006;
s.close();
s.open("d:\\huige1.txt",ios::in);
x.open("d:\\huige2.txt",ios::out);
c=s.get();
while(!s.eof())
{
x.put(c);
c=s.get();
}
s.close();
x.close();
s.open("d:\\huige1.txt",ios::in);
s>>ch>>num;
cout<<ch<<" "<<num<<endl;
s.close();
}
#define n 8
#include<iostream.h>
#include<conio.h>
class stu
{float grade;
float xuefen;
public:
void input();
float avr();
float avr2();
stu(){}
};
void stu::input()
{cout<<"輸入成績,學分:";
cin>>grade>>xuefen;
}
float stu::avr()
{return grade*xuefen;
}
float stu::avr2()
{return xuefen;
}
void main()
{stu s[n];float j1=0,j2=0;int i;
cout<<"-=-=-=-=-=-=-=-=-=計算平均成績-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"<<endl;
cout<<"-=-=-=-=-=-=-=-=-=2006-11-14編寫-=-=-=-=-=-=-=-=-=-=-=-=-=-"<<endl;
for( i=0;i<n;i++)
{cout<<"輸入"<<n<<"門課的成績和學分:\n";
s[i].input();
j1=j1+s[i].avr();
j2=j2+s[i].avr2();
}
cout<<"平均成績="<<j1/j2<<endl;
getch();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -