Yam Code
Sign up
Login
New paste
Home
Trending
Archive
English
English
Tiếng Việt
भारत
Sign up
Login
New Paste
Browse
#include <stdio.h> #include <conio.h> #include <math.h> #include <string.h> struct DATE { int ngay, thang, nam; }; struct SV { char MSSV [15]; char hoTen [50]; DATE ns; float diemTB; }; void nhap1SV (SV &x) { printf("\nMSSV: "); fflush (stdin); scanf("%s", &x.MSSV); printf("Ho ten: "); fflush (stdin); gets(x.hoTen); printf("Ngay/thang/nam sinh: "); scanf("%02d %*c %02d %*c %4d", &x.ns.ngay, &x.ns.thang, &x.ns.nam); printf("Diem TB: "); scanf("%f", &x.diemTB); } void nhapDSSV (SV x[], int &n) { fflush(stdin); for(int i=0; i<n; i++) { printf("\nNhap SV thu %d", i+1); nhap1SV(x[i]); } } void xuatDSSV (SV x[], int n) { printf("\nMSSV \t\t\t Ho ten \t\t\t Ngay sinh \t\t DiemTB"); for (int i=0; i<n; i++) { printf("\n%s \t\t\t %s \t\t\t\t %02d/%02d/%4d \t\t %f", x[i].MSSV, x[i].hoTen, x[i].ns.ngay, x[i].ns.thang, x[i].ns.nam, x[i].diemTB); printf("\n------------------------------------------------------------------------------"); } } void timThongTinTheoMSSV (SV x[], int n) { int i=0; char MaSo [15]; printf("\n\tTIM KIEM THONG TIN SV THEO MSSV"); printf("\nNhap MSSV: "); fflush(stdin); gets(MaSo); printf("\nDanh sach SV duoc tim thay la: "); for(int i=0; i<n; i++) if (strcmp(x[i].MSSV, MaSo) == 0) { printf("\nMSSV \t\t Ho ten \t\t Ngay sinh \t\t DiemTB"); printf("\n%s \t\t %s ", x[i].MSSV, x[i].hoTen); printf("\t\t %02d/%02d/%4d \t\t%2.1f", x[i].ns.ngay, x[i].ns.thang, x[i].ns.nam, x[i].diemTB); break; } if (i == n) printf("Khong tim thay SV nao."); } void suaDiem(SV x[], int n) { int i=0; char MaSo [15]; printf("\n------------------------------------------------------------------------------"); printf("\n\t TIM SV DUA VAO MSSV, SUA LAI DIEMTB"); printf("\nNhap MSSV: "); fflush(stdin); gets(MaSo); for(int i=0; i<n; i++) if (strcmp(x[i].MSSV, MaSo) == 0) { printf("\nNhap lai diem TB: "); scanf("%f", &x[i].diemTB); } if (i==n) printf("Khong tim thay SV nao."); } void sapXepTheoMSSV(SV x[], int n) { SV a; int i,j; for (int i=0; i<n-1; i++) for (int j=i+1; j<n; j++) if (strcmp (x[i].MSSV, x[j].MSSV) > 0) { a = x[i]; x[i] = x[j]; x[j] = a; } } void sapXepTheoDTB(SV x[], int &n) { SV tmp; int i, j; for (i=0; i<n-1; i++) for (j=0; j<n; j++) if (x[i].diemTB > x[j].diemTB) { tmp = x[i]; x[i] = x[j]; x[j] = tmp; } } void timAvaXoaTheoMSSV (SV x[], int &n, char MaSo[]) { printf("\n------------------------------------------------------------------------------"); printf("\n\t\t TIM SV BANG MSSV, XOA SV RA KHOI DANH SACH"); printf("\nNhap MSSV: "); fflush(stdin); gets(MaSo); for(int i=0; i<n; i++) if (strcmp (x[i].MSSV, MaSo) == 0) { // xoa SV thu i for (int j=0; j<n-1; j++) x[i] = x[j+1]; // xoa xong printf("\nDanh sach sv con lai la: "); n--; return; } printf("\n\nTrong DSSV khong co ma A nay!"); } int main() { SV x[15]; int n, chon; char maMuonXoa [15]; while (true) { printf("\n\t----CHUONG TRINH QUAN LY SINH VIEN C----"); printf("\n\t 1. Xuat danh sach SV"); printf("\n\t 2. Sua diem cua mot SV bat ky"); printf("\n\t 3. Tim kiem thong tin SV dua vao viec nhap MSSV"); printf("\n\t 4. Sap xep SV theo MSSV"); printf("\n\t 5. Sap xep thu hang SV theo DTB"); printf("\n\t 6. Xoa SV ra khoi danh sach dua tren MSSV"); printf("\n\t 0. Thoat. "); printf("\n\t--------------------------------------------------"); do { printf("\nNhap so luong SV (0<n<=15): "); scanf("%d", &n); } while (n<=0 || n>15); printf("\n\tNHAP DANH SACH SV"); nhapDSSV(x,n); printf("\n\nNhap tuy chon: "); fflush(stdin); scanf("%d", &chon); switch(chon) { case 1: printf("\n\t 1.XUAT DANH SACH SV\n"); xuatDSSV(x,n); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 2: printf("\n\t 2. SUA DIEM CUA MOT SINH VIEN BAT KY\n"); suaDiem(x,n); xuatDSSV(x,n); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 3: printf("\n\t 3. TIM KIEM THONG TIN SV DUA VAO VIEC NHAP MSSV\n"); timThongTinTheoMSSV(x,n); // xuatDSSV(x,n); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 4: printf("\n\t 4. SAP XEP SV THEO MSSV\n"); sapXepTheoMSSV(x,n); xuatDSSV(x,n); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 5: printf("\n\t 5. SAP XEP THU HANG SV THEO DTB\n"); sapXepTheoDTB(x,n); xuatDSSV(x,n); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); getch(); break; case 6: printf("\n\t 6. XOA SV RA KHOI DS DUA TREN MSSV\n"); timAvaXoaTheoMSSV(x,n,maMuonXoa); xuatDSSV(x,n); printf("\nNhan 1 phim bat ky de tiep tuc.\n"); break; case 0: printf("\nBan da chon thoat chuong trinh!"); getch(); return 0; default: printf("\nKhong co chuc nang nay!"); printf("\nHay chon chuc nang hop le!"); break; } } return 1; }
Paste Settings
Paste Title :
[Optional]
Paste Folder :
[Optional]
Select
Syntax Highlighting :
[Optional]
Select
Markup
CSS
JavaScript
Bash
C
C#
C++
Java
JSON
Lua
Plaintext
C-like
ABAP
ActionScript
Ada
Apache Configuration
APL
AppleScript
Arduino
ARFF
AsciiDoc
6502 Assembly
ASP.NET (C#)
AutoHotKey
AutoIt
Basic
Batch
Bison
Brainfuck
Bro
CoffeeScript
Clojure
Crystal
Content-Security-Policy
CSS Extras
D
Dart
Diff
Django/Jinja2
Docker
Eiffel
Elixir
Elm
ERB
Erlang
F#
Flow
Fortran
GEDCOM
Gherkin
Git
GLSL
GameMaker Language
Go
GraphQL
Groovy
Haml
Handlebars
Haskell
Haxe
HTTP
HTTP Public-Key-Pins
HTTP Strict-Transport-Security
IchigoJam
Icon
Inform 7
INI
IO
J
Jolie
Julia
Keyman
Kotlin
LaTeX
Less
Liquid
Lisp
LiveScript
LOLCODE
Makefile
Markdown
Markup templating
MATLAB
MEL
Mizar
Monkey
N4JS
NASM
nginx
Nim
Nix
NSIS
Objective-C
OCaml
OpenCL
Oz
PARI/GP
Parser
Pascal
Perl
PHP
PHP Extras
PL/SQL
PowerShell
Processing
Prolog
.properties
Protocol Buffers
Pug
Puppet
Pure
Python
Q (kdb+ database)
Qore
R
React JSX
React TSX
Ren'py
Reason
reST (reStructuredText)
Rip
Roboconf
Ruby
Rust
SAS
Sass (Sass)
Sass (Scss)
Scala
Scheme
Smalltalk
Smarty
SQL
Soy (Closure Template)
Stylus
Swift
TAP
Tcl
Textile
Template Toolkit 2
Twig
TypeScript
VB.Net
Velocity
Verilog
VHDL
vim
Visual Basic
WebAssembly
Wiki markup
Xeora
Xojo (REALbasic)
XQuery
YAML
HTML
Paste Expiration :
[Optional]
Never
Self Destroy
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Status :
[Optional]
Public
Unlisted
Private (members only)
Password :
[Optional]
Description:
[Optional]
Tags:
[Optional]
Encrypt Paste
(
?
)
Create New Paste
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Site Languages
×
English
Tiếng Việt
भारत