Yam Code
Sign up
Login
New paste
Home
Trending
Archive
English
English
Tiếng Việt
भारत
Sign up
Login
New Paste
Browse
#include <bits/stdc++.h> using namespace std; struct MedicalEquipment { string type; string ngaythang; string ten; int soluong; int dongia; }; MedicalEquipment ThietBi[100]; int so_luong = 0; //===================================== void clr() { system("cls"); } //===================================== void spau() { system("pause"); } //===================================== void readdata() { ifstream file; file.open("data.txt", ios::app); int i = 0; while (!file.eof()) { file >> ThietBi[i].type >> ThietBi[i].ngaythang >> ThietBi[i].ten >> ThietBi[i].soluong >> ThietBi[i].dongia; i++; } so_luong = i; file.close(); } //===================================== void writedata(int i) { // i la vi tri thiet bi ofstream file; file.open("data.txt", ios::app); file << ThietBi[i].type << '\n' << ThietBi[i].ngaythang << '\n' << ThietBi[i].ten << '\n' << ThietBi[i].soluong << '\n' << ThietBi[i].dongia << '\n'; file.close(); so_luong++; } //===================================== string get_current_date() { // lấy thời gian hiện tại time_t now = time(nullptr); tm *local_time = localtime(&now); // truy xuất ngày tháng năm int day = local_time->tm_mday; int month = local_time->tm_mon + 1; // tm_mon: 0-11 int year = local_time->tm_year + 1900; // tm_year: số năm kể từ 1900 // chuyển đổi sang định dạng string string date_str = to_string(day) + "/" + to_string(month) + "/" + to_string(year); return date_str; } //===================================== void nhaphang() { int soloaithietbi, i; cout << "\nSo loai thiet bi nhap vao: "; cin >> soloaithietbi; for (i = 0; i < soloaithietbi; i++) { ThietBi[i + so_luong].type = "nhap"; ThietBi[i + so_luong].ngaythang = get_current_date(); cout << "\nTen thiet bi: "; cin >> ThietBi[i + so_luong].ten; cout << "So luong: "; cin >> ThietBi[i + so_luong].soluong; cout << "Don gia: "; cin >> ThietBi[i + so_luong].dongia; writedata(i + so_luong); } // readdata(); // so_luong+=soloaithietbi; } //===================================== void xuathang() { int soloaithietbi, i; cout << "\nSo loai thiet bi xuat ra: "; cin >> soloaithietbi; for (i = 0; i < soloaithietbi; i++) { ThietBi[i + so_luong].type = "xuat"; ThietBi[i + so_luong].ngaythang = get_current_date(); cout << "Ten thiet bi: "; cin >> ThietBi[i + so_luong].ten; cout << "So luong: "; cin >> ThietBi[i + so_luong].soluong; cout << "Don gia: "; cin >> ThietBi[i + so_luong].dongia; writedata(i + so_luong); } // so_luong+=soloaithietbi; } void timkiem_lsnhap() { int n, dem = 0; cout << "Ban muon tim kiem bang gi:\n"; cout << "1.Ngay nhap hang:\n"; cout << "2.Ten thiet bi:\n"; cout << "Vui long chon: "; cin >> n; switch (n) { case 1: { cout << "Nhap ngay: "; string date; fflush(stdin); cin >> date; for (int i = 0; i < so_luong; i++) { if (date == ThietBi[i].ngaythang && ThietBi[i].type == "nhap") { cout << "\nNgay: " << ThietBi[i].ngaythang << "Ten: " << ThietBi[i].ten << "\nSo luong: " << ThietBi[i].soluong << "\nDon gia:" << ThietBi[i].dongia << "\n"; dem++; } } if (dem == 0) { cout << "Khong co lich su\n"; } spau(); } break; case 2: { cout << "Nhap ten thiet bi: "; string ten_thietbi; fflush(stdin); cin >> ten_thietbi; for (int i = 0; i < so_luong; i++) { if (ten_thietbi == ThietBi[i].ten && ThietBi[i].type == "nhap") { cout << "ngay: " << ThietBi[i].ngaythang << "\nSo luong: " << ThietBi[i].soluong << "\nDon gia:" << ThietBi[i].dongia << "\n\n"; dem++; } } if (dem == 0) { cout << "Khong co lich su\n"; } spau(); } break; default: break; } } //===================================== void timkiem_lsxuat() { int n, dem = 0; cout << "Ban muon tim kiem bang gi:\n"; cout << "1.Ngay nhap hang:\n"; cout << "2.Ten thiet bi:\n"; cout << "Vui long chon: "; cin >> n; switch (n) { case 1: { cout << "Nhap ngay: "; string date; fflush(stdin); cin >> date; for (int i = 0; i < so_luong; i++) { if (date == ThietBi[i].ngaythang && ThietBi[i].type == "xuat") { cout << "Ten: " << ThietBi[i].ten << "\nSo luong: " << ThietBi[i].soluong << "\nDon gia:" << ThietBi[i].dongia << "\n\n"; dem++; } } if (dem == 0) { cout << "Khong co lich su\n"; } spau(); } break; case 2: { cout << "Nhap ten thiet bi: "; string ten_thietbi; fflush(stdin); cin >> ten_thietbi; for (int i = 0; i < so_luong; i++) { if (ten_thietbi == ThietBi[i].ten && ThietBi[i].type == "xuat") { cout << "Ngay: " << ThietBi[i].ngaythang << "\nSo luong: " << ThietBi[i].soluong << "\nDon gia:" << ThietBi[i].dongia << "\n\n"; dem++; } } if (dem == 0) { cout << "Khong co lich su\n"; } spau(); } break; default: break; } } //===================================== void timkiem_soluong() { int t = 0; string tenthietbi; cout << "Ten thiet bi ban can tim la: "; // fflush(stdin); cin >> tenthietbi; for (int i = 0; i < so_luong; i++) { if (ThietBi[i].ten == tenthietbi) { if (ThietBi[i].type == "nhap") { t += ThietBi[i].soluong; } else { t -= ThietBi[i].soluong; } } } if (t != 0) { cout << "So " << tenthietbi << " con lai: " << t << "\n\n"; } else { cout << "Khong co thiet bi"; } spau(); } //===================================== void timkiem() { int n; cout << "Ban muon tim kiem gi:\n"; cout << "1, Lich su nhap hang.\n"; cout << "2, Lich su xuat hang.\n"; cout << "3, So luong hang con cua thiet bi.\n"; cout << "Vui long chon: "; cin >> n; switch (n) { case 1: timkiem_lsnhap(); break; case 2: timkiem_lsxuat(); break; case 3: timkiem_soluong(); break; default: break; } } //===================================== void menu() { int luachon; cout << " QUAN LI KHO THIET BI Y TE \n"; cout << "1. Nhap hang vao kho.\n"; cout << "2. Xuat hang ra kho.\n"; cout << "3. Tim kiem.\n"; cout << "4. Thoat.\n"; cout << "Vui long chon: "; cin >> luachon; switch (luachon) { case 1: nhaphang(); break; case 2: xuathang(); break; case 3: timkiem(); break; case 4: exit(0); break; default: cout << "Error\n"; spau(); break; } } int main() { readdata(); while (1) { clr(); menu(); }; return 0; }
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
भारत