Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. int Cong(int a,int b)
  4. {
  5. return a+b;
  6. }
  7. void Hello()
  8. {
  9. printf("Hello");
  10. }
  11. bool SNT(int n)
  12. {
  13. for(int i=2;i<n;i++)
  14. if(n%i==0) return false;
  15. return true;
  16. }
  17. main()
  18. {
  19. printf("\n*****************************");
  20. printf("\n* MENU *");
  21. printf("\n* Bai Hello bam phim 1 *");
  22. printf("\n* Bai SNT bam phim 2 *");
  23. printf("\n* Bai Cong bam phim 3 *");
  24. printf("\n*****************************");
  25. char Nhap;
  26. scanf(" %c",&Nhap);
  27. if(Nhap=='1') Hello();
  28. else if(Nhap=='2')
  29. {
  30. int SoMoi;
  31. printf("\nMoi nhap so can kiem tra: ");
  32. scanf("%d",&SoMoi);
  33. if(SNT(SoMoi)==true) printf("\nSo %d la SNT",SoMoi);
  34. else printf("\nS %d ko phai la SNT",SoMoi);
  35. }
  36. else if(Nhap=='3')
  37. {
  38. int SoThuNhat, SoThuHai;
  39. printf("\nMoi nhap 2 so can cong: ");
  40. scanf("%d %d", &SoThuNhat,&SoThuHai);
  41. printf("%d + %d = %d",SoThuNhat,SoThuHai,Cong(SoThuNhat,SoThuHai));
  42. }
  43. else
  44. {
  45. printf("\nChon menu ko dung");
  46. }
  47. getch();
  48. }
  49. #include <stdio.h>
  50. #include <conio.h>
  51. int Cong(int a,int b)
  52. {
  53. return a+b;
  54. }
  55. void Hello()
  56. {
  57. printf("Hello");
  58. }
  59. bool SNT(int n)
  60. {
  61. for(int i=2;i<n;i++)
  62. if(n%i==0) return false;
  63. return true;
  64. }
  65. main()
  66. {
  67. printf("\n*****************************");
  68. printf("\n* MENU *");
  69. printf("\n* Bai Hello bam phim 1 *");
  70. printf("\n* Bai SNT bam phim 2 *");
  71. printf("\n* Bai Cong bam phim 3 *");
  72. printf("\n*****************************");
  73. char Nhap;
  74. scanf(" %c",&Nhap);
  75. if(Nhap=='1') Hello();
  76. else if(Nhap=='2')
  77. {
  78. int SoMoi;
  79. printf("\nMoi nhap so can kiem tra: ");
  80. scanf("%d",&SoMoi);
  81. if(SNT(SoMoi)==true) printf("\nSo %d la SNT",SoMoi);
  82. else printf("\nS %d ko phai la SNT",SoMoi);
  83. }
  84. else if(Nhap=='3')
  85. {
  86. int SoThuNhat, SoThuHai;
  87. printf("\nMoi nhap 2 so can cong: ");
  88. scanf("%d %d", &SoThuNhat,&SoThuHai);
  89. printf("%d + %d = %d",SoThuNhat,SoThuHai,Cong(SoThuNhat,SoThuHai));
  90. }
  91. else
  92. {
  93. printf("\nChon menu ko dung");
  94. }
  95. getch();
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement