while(!in.eof()) {
ch=in.get(); if (islower(ch))
ch=toupper(ch); else
ch=tolower(ch); out.put(ch); } }
实验题2参考程序 #include
int getnum(char *); char buf[100];
while (getnum(buf)){
cout << \ cout << buf << endl; }
return 0;}
int getnum(char *s){ *s = '\\0'; char ch;
while (cin.get(ch) && !cin.eof() && !isdigit(ch)) ;//去掉前面的非数字字符 do
*s++ = ch; //读入数字串
while (cin.get(ch) && !cin.eof() && isdigit(ch)); *s = '\\0';
if (!cin.eof()) cin.putback(ch); //A if (!cin || cin.eof()) return 0; //B return 1; }
实验题3参考程序
#include
public:
char name[10]; int num; int age;
char addr[15];
friend ostream & operator<<(ostream &out,student &s);
friend ostream & operator<<(istream &in,student &s); };
ostream & operator<<(ostream &out,student &s) {
out<
istream & operator>>(istream &in,student &s) {
int i=0; char c; while(1) {
in>>c; if (c!=',') {
s.name[i]=c; } else {
s.name[i]='\\0'; break; } i++; }
in>>s.num>>c>>s.age>>c; i=0;
in.getline(s.addr,15); return in; }
void main() {
ofstream ofile(\
student s[3];
for (int i=0;i<3;i++) {
cin>>s[i]; ofile<
ifstream ifile(\
for (i=0;i<3;i++) {
ifile>>s[i]; cout<
【思考题】
1.了解一下cin的产生过程。
2.二进制文件和文本文件有什么不同?
实验六 Windows编程基础 【实验类型】验证性 【实验要求】必做
【实验目的】
1.了解windows程序设计中的相关概念(句柄,消息等等)。
2.掌握Windows程序运行原理及程序编写流程。掌握构建基本窗口框架程序的相关API函数。
3.掌握窗口创建过程及回调函数的原理和使用方法。 4.了解常用windows消息 【实验内容】
实验题1. 调试课堂windows窗口程序。
实验题2. 编写windows窗口程序,求解一元二次方程根,方程系数在程序中直接给出,将结果显示到窗口上即可,如图所示。
实验题3. 修改实验题2,在窗口中加入基本控件,要求在控件中输入方程系数,求解一元二次方程。如图所示。
【参考程序】 实验题1参考程序
#include
#include
相关推荐: