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

 
PageRank là gì?

Google Pagerank là gì?

Trước tiên chúng ta tìm hiểu lại khái niệm website một chút. Website là tập hợp các trang web, tương tự như một cuốn sách là tập hợp các trang sách. Với các bạn đã từng thiết kế website chắc không xa lạ gì với khái niệm này.

[KDS] Keeping Drupal Simple và Static Prototyping

[KDS] Keeping Drupal Simple và Static Prototyping

The technical debt involved with preprocessing views templates or creating custom panel layouts is hard to justify for projects that have small budgets, tight timelines, or hyper-specific design requirements.

D8FTW: DIC Core Without Killing Kittens

D8FTW: DIC Core Without Killing Kittens

The upcoming Drupal 8 includes many changes large and small that will improve the lives of site builders, site owners, and developers. In a series we're calling, "D8FTW," we look at some of these improvements in more detail, including and especially the non-obvious ones.

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

 

Diet con trung