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

 
Sử dụng Bootswatch Themes ở Drupal 7 như thế nào?

Sử dụng Bootswatch Themes ở Drupal 7 như thế nào?

The standard look and feel of Bootstrap is unmistakable and often you can spot a website using it a mile away. The dead giveaways are the buttons and navigation, but it doesn't have to be this way.

Hướng dẫn đơn giản Entity Data API cho Module Builders

Hướng dẫn đơn giản Entity Data API cho Module Builders

Fields are a powerful way to add data to Drupal entities. However, sometimes fields can be rather cumbersome.

Bước 1: Understanding typical teams, roles and skills

Bước 1: Understanding typical teams, roles and skills of team Drupal

In order to successfully create a great digital experience with Drupal, you need a great Drupal team. Building a great team requires some thoughtful planning and possibly widening your net a bit. In this blog series, we'll be looking at the 5 Steps to Build a Great Drupal Team.

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

 

Diet con trung