#include
#include
#include
#include
#include
#pragma comment(lib,"ws2_32")
#pragma comment(lib,"libmysql")
using namespace std;
class Student
{
int id;
char name[200];
char sex[100];
char min_zu[220];
char ji_guan[330];
char sheng_fen_zheng_hao[20];
char QQ[20];
char phone[20];
int score;
public:
void show_table();
int main_menu();
void input();
int xiu_gai();
int xiu_gai_menu();
int cha_xun();
int cha_xun_menu();
int del();
int shan_menu();
int score_tong_ji();
int score_tong_ji_menu();
};
class Xu_gai:public Student//改动类
{
public:
void xiu_gai_xue_hao();
void xiu_gai_xing_ming();
void xiu_gai_xing_bie();
void xiu_gai_min_zu();
void xiu_gai_ji_guan();
void xiu_gai_shen_fen_zheng_hao();
void xiu_gai_QQ_hao();
void xiu_gai_dian_hua();
void xiu_gai_cheng_ji();
};
class Cha_xun:public Student//查询类
{
public:
void xue_hao_cha_xun();
void xing_ming_cha_xun();
};
class Shan_chu:public Student//删除类
{
public:
void xue_hao_shan_chu();
void xing_ming_shan_chu();
};
class Score:public Student//成绩统计类
{
public:
void cheng_ji_pai_xu();
void zui_gao_zui_di_fen_xin_xi();
void ping_jun_fen();
void ji_ge_lv();
};
void Score::ji_ge_lv()//全体学生的及格率
{
Student zhao;
system("pause");
system("cls");
zhao.show_table();
MYSQL mysql;
mysql_init(&mysql);
MYSQL_RES *resultset;
MYSQL_ROW row;
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, "latin1");
if(!mysql_real_connect(&mysql, "localhost", "root", "123456", "student", 3306, NULL, 0))
{
printf("\n数据库连接错误发生!");
}
else
{
float a,b;
mysql_query(&mysql,"select count(*) from xueji where score >= 450");
cout<
resultset=mysql_store_result(&mysql);
if(mysql_num_rows(resultset)!=NULL)
{
int numFields = mysql_num_fields(resultset);
while(row=mysql_fetch_row(resultset))
{
cout<
a = atoi(row[0]);
cout<
}
}
mysql_query(&mysql,"select count(*) from xueji");
cout<
resultset=mysql_store_result(&mysql);
if(mysql_num_rows(resultset)!=NULL)
{
int numFields = mysql_num_fields(resultset);
while(row=mysql_fetch_row(resultset))
{
cout<
b = atoi(row[0]);
cout<
}
}
cout<
cout << ((a/b)*100)<
mysql_free_result(resultset);
}
}
void Score::ping_jun_fen()//全体学生的平均分
{
Student zhao;
system("pause");
system("cls");
zhao.show_table();
MYSQL mysql;
mysql_init(&mysql);
MYSQL_RES *resultset;
MYSQL_ROW row;
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, "latin1");
if(!mysql_real_connect(&mysql, "localhost", "root", "123456", "student", 3306, NULL, 0))
{
printf("\n数据库连接错误发生!");
}
else
{
float a,b;
mysql_query(&mysql,"select avg(score) from xueji");
cout<
resultset=mysql_store_result(&mysql);
if(mysql_num_rows(resultset)!=NULL)
{
int numFields = mysql_num_fields(resultset);
while(row=mysql_fetch_row(resultset))
{
cout<
a = atoi(row[0]);
cout<
}
}
mysql_free_result(resultset);
}
}
void Score::zui_gao_zui_di_fen_xin_xi()//最高最低分学生的信息
{
Student zhao;
system("pause");
system("cls");
zhao.show_table();
MYSQL mysql;
mysql_init(&mysql);
MYSQL_RES *resultset;
MYSQL_ROW row;
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, "latin1");
if(!mysql_real_connect(&mysql, "localhost", "root", "123456", "student", 3306, NULL, 0))
{
printf("\n数据库连接错误发生!");
}
else
{
float a,b;
mysql_query(&mysql,"select max(score) from xueji");
cout<
resultset=mysql_store_result(&mysql);
if(mysql_num_rows(resultset)!=NULL)
{
int numFields = mysql_num_fields(resultset);
while(row=mysql_fetch_row(resultset))
{
cout<
a = atoi(row[0]);
cout<
}
}
mysql_query(&mysql,"select min(score) from xueji");
cout<
resultset=mysql_store_result(&mysql);
if(mysql_num_rows(resultset)!=NULL)
{
int numFields = mysql_num_fields(resultset);
while(row=mysql_fetch_row(resultset))
{
cout<
b = atoi(row[0]);
cout<
}
}
mysql_free_result(resultset);
}
}
void Score::cheng_ji_pai_xu()//成绩排序
{
Student