This web page requires JavaScript to be enabled.

JavaScript is an object-oriented computer programming language commonly used to create interactive effects within web browsers.

How to enable JavaScript?

Tin học Thực hành 7 made in PHƯƠNG

10cth1-2 December 9, 2010 2

bài bên dưới của mình, tuy chẳng giống ai nhưng cũng đều cho chung kết quả. bởi vì: tự tay mình làm. mỗi người làm 1 kiểu.
bài của mình khai báo biến không gán &n . đọc vào dễ hiểu hơn.

[codes=c]
#include <stdio.h>
#include <conio.h>
void nhapso(int n)
{
  printf("nhap vao n:");
  scanf("%d",&n);
  printf(" ban vua nhap vao so %d\n",n);
}
void lietke(int  n)
{
  printf("nhap vao n:");
  scanf("%d",&n);
  printf("so chan khong chia het cho 3 la:\n");
for (int i=1;i<=n;i++)
{
if (i% 2 ==0 || i%3!=0)
{
printf("%3d",i);
}
}
}
void sohoanthien(int n)
{
  int s=0;
    printf("nhap vao n:");
  scanf("%d",&n);

      for (int i=1;i<n;i++)
    if (n%i==0) s+=i;
            if (s==n) printf("\n %d la so hoan thien\n\n",n);
                else printf("\n %d khong phai la so hoan thien\n\n",n);
}

void timucln(int a, int b)
{
  printf("nhap vao 2 so a,b:");
  scanf("%d%d",&a,&b);

while (a!=b )
    {
  if (a>b)
  a =( a – b);
  else b = b-a;
  }
printf("UCLN la: %d", a);
}

void main()
{
int  n,a,b;
int chon;
do{
  clrscr;
  printf("\n \t\t**********THUC DON CONG VIEC**********\n\n");
  printf("\t1: nhap vao so nguyen n \n");
  printf("\t2: liet ke cac so chan khong chica het cho 3 tu 1 den n\n");
  printf("\t3: cho biet n co phai la so hoan thien khong?\n");
  printf("\t4: tim uoc chugn lon nhat cua 2 so nhap tu ban phim\n");
  printf("\t Hay chon cong viec:");
  scanf("%d",&chon);

  switch (chon)
  {
  case 1: nhapso(n);
  getch();
    break;
  case 2: lietke(n);
  getch();
    break;
  case 3:sohoanthien(n);
  getch();
    break;
  case 4: timucln(a,b) ;
  getch();
    break;
  case 0: getch();

    break ;
  }
}
while ( chon!=0);
}[/codes]


Last modified on December 9th, 2020 at 1:54 am

pithu_cth01
pithu_cth01



2 responds

  1. le.qnam says:

    Phương gửi bài đúng chuyên mục nha. [emot]thumbdown[/emot]

  2. JacksoTai says:

    lớp mình nhìu nhân tài quá

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.