⑴ C++面向對象程序設計試題
一、1.C 2.D 3.A 4.A 5.C 6.B 7.B 8.C 9.D 10.B 11.A 12.B 13.B 14.C 15.C
二、1.封裝、繼承、多態;2.傳值、傳址;3.Template;4.~student();5.私有;6.參數、返回值;7.優先順序、結合性、運算順序;8.代碼的復用、MFC編程;9.X、Y;10.new
⑵ C++語言是一種面向對象的程序設計語言。這個面向對象指的是什麼
面向對象是不同於面向過程的一種編程思想。它是將自己搞不定的事或做起來比較版費力的事委託給信權任的人來做(如VC++中的可視化組具體是怎麼來的,我們不用擔心,只要知道怎麼用就行);面向過程是事無大小均由自己完成,從底層到頂層,從內部到外部。舉例說明:面向對象像是皇帝,吃喝拉撒都由太監宮女搞定,治理國家由文武百官搞定,他只要會用人、決策、享受主行;而面向過程就像是百姓,吃,自己種地,喝,自己挖井,穿,自己織布等等
⑶ 《面向對象程序設計》課程設計
學生信息管理系統,給你一部分程序,符合要求把你郵箱發給我。#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include <math.h>
#include"form.h"
#include"add.h"extern int count;
////////////////////////////函數聲明//////////////////////////
void sortdate(); //2.記錄排序
void printreport(struct student *head); //3.列印學生成績
void searchstudents(); //6.查詢學生信息
void statscore(); //7.統計成績
void out(); //0.退出
int total(struct student *nod); //計算總分
int zavg(struct student *nod); //計算平均分整數部分
int xavg(struct student *nod); //計算平均分小數部分
void SortAllData(struct student *head,int count, int (*p)());//排序
int CompareSnoAsc(struct student *p,struct student *q); //學號升序////////////////////////////函數實現//////////////////////////
void main()
{
winwelcome();
do{
system("cls");
winmenulist();
onlyoneinput(56,16); //輸入單個選項
switch(key)
{
case '1': //1.添加學生信息
addstudentinfo();
break;
case '2': //2.記錄排序
sortdate();
break;
case '3': //3.列印學生成績
printreport(head);
break;
case '6': //6.查詢學生信息
searchstudents();
break;
case '7': //7.統計成績
statscore();
break;
case '0':
out();
continue;
case '\r':
continue;
case ' ':
continue;
default:
goxy(2,20);
putchar(key);
printf(" is a error number, please input a number between 0 to 7");
goxy(2,21);
printf("Press any key to continue");
getch();
}
}while(1);
}/////////////////////////2.記錄排序//////////////////////////
void sortdate()
{
while (1)
{
system("cls");
winsortdate();
onlyoneinput(55,17);
switch(key)
{
case '1': //按學號升序排
system("cls");
winstudengrade();
goxy(31,3);
printf("Rise By Student Number");
// SortAllData(head,count,CompareSnoAsc);
goxy(1,21);
printf("Press any key to continue");
getch();
break;
case '2': //按學號降序排
winstudengrade();
goxy(33,3);
printf("Descend By Number");
goxy(1,21);
printf("Press Any Key To Continue");
break;
case '3': //按總分升序排
winstudengrade();
goxy(35,3);
printf("Rise By Total");
goxy(1,21);
printf("Press Any Key To Continue");
break;
case '4': //按總分降序排
winstudengrade();
goxy(34,3);
printf("Descend By Total");
goxy(1,21);
printf("Press Any Key To Continue");
break;
//case 5:
default:
goxy(2,20);
putchar(key);
printf(" is a error number, please input a number between 0 to 4");
goxy(2,21);
printf("press any key to continue");
getch();
}
}
}///////////////////////////3.列印學生成績/////////////////////////
void printreport(struct student *head)
{
int i,j,page=1;
struct student *node;
node=head;
while(node)
{
system("cls");
winstudengrade();
goxy(31,3);
printf("Print Student's Report");
j=8;
for(i=1;i<=10;i++,j++)
{
goxy(1,j);
printf("%s",node->sno);
goxy(6,j);
printf("%s",node->name);
goxy(26,j);
printf("%s",node->age);
goxy(30,j);
printf("%3d",node->chinese);
goxy(38,j);
printf("%3d",node->english);
goxy(46,j);
printf("%3d",node->math);
goxy(51,j);
printf("%3d",node->physics);
goxy(59,j);
printf("%3d",node->chemistry);
goxy(69,j);
printf("%3d",total(node));
goxy(75,j);
printf("%2d.%d",zavg(node),xavg(node));
node=node->next;
if (node==NULL)
break;
}
goxy(2,20);
printf("Press up key to up page");
goxy(2,21);
printf("Press down key to next page");
goxy(2,22);
printf("Press esc key to exit");
while(1)
{
key=getch();
if (key==27)
return;
if (key<=0)
{
key=getch();
if (key==72&&page!=1) //向上翻頁
{
node=node-10;
page--;
break;
}
if (key==80&&node!=NULL) //向下翻頁
{
page++;
break;
}
}
}
}
}///////////////////////////6.查詢學生信息//////////////////////////
void searchstudents()
{
scanf("%d",key);
system("cls");
switch(key)
{
case '1':
winstudengrade();
goxy(33,3);
printf("Search By Number");
goxy(1,21);
printf("Please Input Any Key TO Continue");
break;
case '2':
winstudengrade();
goxy(35,3);
printf("Search By Name");
goxy(1,21);
printf("Please Enter Any Key TO Continue");
// case 3:
//返回上級目錄
}
}///////////////////////////7.統計成績/////////////////////////
void statscore()
{
winstatscore();
}////////////////////////////0.退出//////////////////////////
void out()
{
while(1)
{
system("cls");
winout();
onlyoneinput(55,11);
if (key=='Y'||key=='y')
exit(0);
else if(key=='N'||key=='n')
break;
else
{
goxy(2,20);
putchar(key);
printf(" is a error option,please input a option ( Y or N )");
goxy(2,21);
printf("please input anykey to continue");
getch();
}
}
}/////////////////////計算總分/////////////////////
int total(struct student *nod)
{
int sum=0;
sum=nod->chinese+nod->english+nod->math+nod->physics+nod->chemistry;
return sum;
}//////////////////計算平均分////////////////////
int zavg(struct student *nod) //整數部分
{
int i=0;
i=total(nod)/5;
return i;
}
int xavg(struct student *nod) //小數部分
{
float i;
int j;
i=total(nod)/5.0;
j=(i-zavg(nod))*10;
return j;
}///////////////////////排序////////////////////////
void SortAllData(struct student *head,int count, int (*p)())
{
struct student *i,*j,*temp=NULL;
i=j=head;
for (i=head;i!=NULL;i=i->next)
{
for (j=i->next;j!=NULL;j=j->next)
{
if ((*p)())
{
temp->pre=i->pre;
temp->next=i->next;
i->pre->next=temp;
i->next->pre=temp;
i->pre=j->pre;
i->next=j->next;
j->pre->next=i;
j->next->pre=i;
j->pre=temp->pre;
j->next=temp->next;
temp->pre->next=j;
temp->next->pre=j;
}
}
}
printreport(head);
}///////////////////////學號升降序/////////////////////int CompareSnoAsc(struct student *p,struct student *q) //學號升序
//{
// return strcmp(p->sno,q->sno)>0;
//}
//int CompareSnoDesc(struct student *p,struct student *q)//學號降序
//{
// return strcmp(p->sno,q->sno)<0;