当前位置:网站首页>A simple examination system based on C language
A simple examination system based on C language
2022-06-22 07:17:00 【Come on, Doo】
Is to define a student class , Record the student number , full name , Exam results, etc .
Implemented function : Entry of examination results , And candidate information entry , Examination results query
Code :
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;
struct Student
{
int ID;
char name[20];
float chinese=0.0;
float math=0.0;
};
int main()
{
vector<Student> Students;
while(true)
{
int n=0;
printf(" Examination system \n");
printf("1. Student information entry \n");
printf("2. Check student grades \n"); // Query by student number
printf("3. Chinese examination \n");
printf("4. Math exam \n");
scanf("%d",&n);
if(n==1)
{
printf(" Please enter the student ID and name in turn , Separate with spaces \n");
Student stu;
scanf("%d%s",&stu.ID,&stu.name);
Students.push_back(stu);
printf(" Student information entered successfully \n");
}else if(n==2)
{
printf(" Please enter the student number to be queried \n");
int id;
scanf("%d",&id);
bool isFind=false;
for(int i=0;i<Students.size();++i)
{
if(id==Students[i].ID)
{
printf(" Student number :%d, full name :%s, Chinese achievement :%.1f, Math scores :%.1f\n",Students[i].ID,
Students[i].name,Students[i].chinese,Students[i].math);
isFind=true;
}
}
if(!isFind)
{
printf(" Students don't exist \n");
}
}else if(n==3)
{
int id;
printf(" Please enter the student number to be tested \n");
scanf("%d",&id);
bool isFind=false;
for(int i=0;i<Students.size();++i)
{
if(id==Students[i].ID)
{
isFind=true;
printf(" Chinese examination , A total of 2 topic , Each question 50 branch \n");
printf(" The first question is \n");
printf(" Why is Li Bai called ?\n");
char ti1[20];
char ti1key[20]=" Poetry fairy ";
scanf("%s",&ti1);
int Source=0;
if(strcmp(ti1,ti1key)==0)
{
Source+=50;
printf(" Correct answer \n");
}else
{
printf(" Wrong answer \n");
}
printf(" The second question is \n");
printf(" Who wrote this poem of Acacia \n");
char ti2[20];
char ti2key[20]=" Wang wei ";
scanf("%s",&ti2);
if(strcmp(ti2,ti2key)==0)
{
Source+=50;
printf(" Correct answer \n");
}else
{
printf(" Wrong answer \n");
}
printf(" The exam is over \n");
printf(" Your Chinese score is %d branch ",Source);
Students[i].chinese=Source;
}
}
if(!isFind)
{
printf(" Students don't exist , Please enter the information before taking the exam \n");
}
}else if(n==4)
{
int id;
printf(" Please enter the student number to be tested \n");
scanf("%d",&id);
bool isFind=false;
for(int i=0;i<Students.size();++i)
{
if(id==Students[i].ID)
{
isFind=true;
printf(" Math exam , A total of 2 topic , Each question 50 branch \n");
printf(" The first question is \n");
printf(" The length of the rectangle is 10, Wide for 5, Then the area of the rectangle is \n");
printf("A 50 B 30\n");
char ti1[20];
char ti1key[20]="A";
char tikey1[20]="a";
scanf("%s",&ti1);
int Source=0;
if(strcmp(ti1,ti1key)==0||strcmp(ti1,tikey1)==0)
{
Source+=50;
printf(" Correct answer \n");
}else
{
printf(" Wrong answer \n");
}
printf(" The second question is \n");
printf(" The three sides of a triangle are 3,4,5, What is a triangle \n");
printf("A an isosceles triangle B Equilateral triangle C right triangle \n");
char ti2[20];
char ti2key[20]="C";
char ti2key2[20]="c";
scanf("%s",&ti2);
if(strcmp(ti2,ti2key)==0||strcmp(ti2,ti2key2)==0)
{
Source+=50;
printf(" Correct answer \n");
}else
{
printf(" Wrong answer \n");
}
printf(" The exam is over \n");
printf(" Your math score is %d branch ",Source);
Students[i].math=Source;
}
}
if(!isFind)
{
printf(" Students don't exist , Please enter the information before taking the exam \n");
}
}
else
{
printf(" Wrong operation , Please do it again \n");
}
}
}

边栏推荐
- 2022年畢業生求職找工作青睞哪個行業?
- CONDA installation method of deepmd kit and the solution of slow speed
- C language - deep understanding of arrays
- About pointer (notes, for personal use)
- JDBC query result set, which is converted into a table
- 【实习】跨域问题
- Speed planning generation of coursera self driving car Part4 motion planning
- JS implementation of random generation of 16 bit key -- Basic accumulation
- [out of distribution detection] deep analog detection with outlier exposure ICLR '19
- Pytorch idea and implementation of keras code conversion for CNN image classification
猜你喜欢

RFID warehouse management system solution implementation visualization process

antd——a-upload-dragger拖拽上传组件——基础积累

流程引擎解决复杂的业务问题

June 21, 2022: golang multiple choice question, what does the following golang code output? A:3; B:4; C:100; D: Compilation failed. package main import ( “fmt“ ) func

Introduction and use of cookies
Tikz learning notes (III) marking and intersection of graphics

Fundamentals of neural network (notes, for personal use)

Theory and application of naturallanguageprocessing

Real MySQL interview question (18) -- practical operation analysis

antd 框架:点击链接重开浏览器页面——基础积累
随机推荐
Pdf to picture implementation
微信小程序伪装页面(定时改变页面内容)
Real MySQL interview questions (20) -- video data analysis practice
Notes on algebra 10.1: understanding of symmetric polynomials and derivation of cubic resolvents
Tpflow v6.0.6 official release
Common evaluation indicators of recommended system: ndcg, recall, precision, hit rate
Convolutional neural network (notes, for personal use)
Neuron+ekuiper realizes data collection, cleaning and anti control of industrial Internet of things
Error: unable to find vcvarsall Solutions to bat errors
ROS QT environment construction
[out of distribution detection] deep analog detection with outlier exposure ICLR '19
Map of STL knowledge summary
5g NR PWS system
Coursera self driving car Part4 motion planning finalproject principle and key code analysis
RT-Thread临界段的保护
如何解决‘WebDriver‘ object has no attribute ‘switch_to_window‘
JS中对数组进行去重的几种方法
About structure (notes, for personal use)
[distributed external detection] Odin ICLR '18
cookie的介绍和使用