Câu 1.10: Viết hàm tìm số bé nhất của 3 số thực. Viết chương trình nhập vào từ bàn phím 3 số thực x, y, z, áp dụng hàm trên tìm và in ra màn hình số bé nhất của 3 số vừa nhập.

Monday, August 11, 2014
// bai10.cpp : Defines the entry point for the console application.
//

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

float min(float x, float y, float z)
{
                float min1=x;
                if (min1>y) min1=y;
                else if (min1>z) min1 = z;
                return min1;
}

int _tmain(int argc, _TCHAR* argv[])
{
                float x,y,z;
                printf("\nNhap 3 so thuc: ");
                scanf("%f%f%f",&x,&y,&z);
                printf("\nmin 3 so %7.3f,%7.3f,%7.3f la %7.3f",x,y,z,min(x,y,z));
                getch();
                return 0;

}
Chia sẻ bài viết ^^
Other post

All comments [ 0 ]


Your comments