Bai7.cpp - #include<stdio.h>#include<conio.h>#include<string.h>#include<windows.h> struct Sinhvien char Ten[21 int n = 0 void Nhapsinhvien(Sinhvien st

Bai7.cpp -...

This preview shows page 1 - 2 out of 2 pages.

#include<stdio.h> #include<conio.h> #include<string.h> #include<windows.h> struct Sinhvien { char Ten[21]; }; int n = 0; void Nhapsinhvien(Sinhvien st[]); void Xuatsinhvien(Sinhvien st[]); int Timsinhvien(Sinhvien st[]); void Sxsinhvien(Sinhvien st[]); void Menu(int &chon); int main() { int chon; Sinhvien st[100]; do { system("CLS"); Menu(chon); switch (chon) { case 1: Nhapsinhvien(st); break; case 2: Xuatsinhvien(st); break; case 3: { int a = Timsinhvien(st); if (a >= 0) printf("Tim thay sv tai vi tri %d", a + 1); else printf("Khong tim thay"); break; } case 4: Sxsinhvien(st); Xuatsinhvien(st); break; case 0: break; default: printf("Chon sai chuc nang!!!"); break; } getch(); }while (chon != 0); return 0; } void Menu(int &chon) { printf("=======MENU============================\n"); printf("1. Nhap sinh vien |\n"); printf("2. In danh sach sinh vien |\n"); printf("3. Tim sinh vien neu co in ra man hinh |\n"); printf("4. Sap xep sinh vien tang dan
Image of page 1

Subscribe to view the full document.

Image of page 2

Unformatted text preview: |\n&quot;); printf(&quot;0. Thoat |\n&quot;); printf(&quot;========================================\n&quot;); printf(&quot;Chon chuc nang:&quot;); scanf(&quot;%d&quot;, &amp;chon); } void Nhapsinhvien(Sinhvien st) { fflush(stdin); printf(&quot;Nhap ho va ten sinh vien:&quot;); scanf(&quot;%[^\n]&quot;, &amp;st[n].Ten); n++; } void Xuatsinhvien(Sinhvien st) { printf(&quot;Danh sach sinh vien:\n&quot;); for (int i = 0; i &lt; n; i++) { printf(&quot;%25s\n&quot;, st[i].Ten); } } int Timsinhvien(Sinhvien st) { char Ten[21]; fflush(stdin); printf(&quot;Nhap ho ten sinh vien can tim:&quot;); gets(Ten); for (int i = 0; i&lt;n ;i++) { if (strcmp(Ten, st[i].Ten) == 0) { return i; } } return -1; } void Sxsinhvien(Sinhvien st) { Sinhvien temp; for (int i = 0; i &lt; n - 1; i++) for (int j = n - 1; j &gt; i; j--) if (st[j].Ten &lt; st[j - 1].Ten) { temp = st[j]; st[j] = st[j - 1]; st[j - 1] = temp; } }...
View Full Document

  • Spring '15
  • Thuy Do

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes