Bài tập 49: Cho số nguyên dương n. Hãy tìm chữ số đầu tiên của n

Bài tập 49: Cho số nguyên dương n. Hãy tìm chữ số đầu tiên của n

Dạng bài tập này giúp các bạn giỏi về: Lưu đồ thuật toán

Bài tập 49: Cho số nguyên dương n. Hãy tìm chữ số đầu tiên của n

Cài đặt

#include<stdio.h>
#include<conio.h>

int main()
{
    int themang, n, i;

    do
    {
        printf("\nNhap n: ");
        scanf("%d", &n);
    }while(n < 0 && printf("\nLoi: (n >= 0)"));

    themang = n;
    /*do
    {                                 
        i = themang % 10;
        themang /= 10;
    }while(themang != 0);*/                
    
    //có thể viết
    do
    {
      i = themang % 10;
    }while(themang /= 10);
    
    printf("\nChu so dau tien la %d", i);

    getch();
    return 0;
}
Bạn thấy bài viết này như thế nào?: 
Average: 10 (8 votes)
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
NewStories, News Comments

Tính năng mới của Facebook App cho iOS

Chuyện gì phải đến đã đến... đêm qua, trong lúc chúng ta ngủ thì ứng dụng Facebook mới, phiên bản 5.0 cho iOS đã được cập nhật.

Google Maps Android Apps Review

Google Maps Android Apps Review

If you like to travel and see the world then you probably understand just how important it is to get your directions right.

Android có thành "li rượu độc" cho Google?

Android có thành "li rượu độc" cho Google?

Với việc giới thiệu Android – hệ điều hành nguồn mở cho smartphone (sau này thêm tablet) và T-Mobile G1, Android được phổ biến trên thị trường smartphone

Công ty diệt chuột T&C

 

Diet con trung