Chương trình C để tìm số lớn nhất trong ba số
Cải thiện bài viết
Lưu bài viết
Thích bài viết
- Độ khó. Cơ bản
- Cập nhật lần cuối. 26 tháng 9 năm 2022
Cải thiện bài viết
Lưu bài viết
Cho ba số A, B, C; .
Đầu vào. A = 2, B = 8, C = 1
Đầu ra. Số lớn nhất = 8Đầu vào. A = 231, B = 4751, C = 75821
Đầu ra. Số lớn nhất = 75821
Khuyến khích. Vui lòng thử cách tiếp cận của bạn trên {IDE} trước, trước khi chuyển sang giải pháp
Trong các chương trình bên dưới, để tìm số lớn nhất trong ba số,
1. Start 2. Read the three numbers to be compared, as A, B and C. 3. Check if A is greater than B. 3.1 If true, then check if A is greater than C. 3.1.1 If true, print 'A' as the greatest number. 3.1.2 If false, print 'C' as the greatest number. 3.2 If false, then check if B is greater than C. 3.1.1 If true, print 'B' as the greatest number. 3.1.2 If false, print 'C' as the greatest number. 4. End
Lưu đồ để tìm số lớn nhất trong ba số.
C
Enter the numbers A, B and C: 2 8 1 8 is the largest number.20
Enter the numbers A, B and C: 2 8 1 8 is the largest number.21
Enter the numbers A, B and C: 2 8 1 8 is the largest number.22
Enter the numbers A, B and C: 2 8 1 8 is the largest number.23
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.21
Enter the numbers A, B and C: 2 8 1 8 is the largest number.1
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.6
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.0
Enter the numbers A, B and C: 2 8 1 8 is the largest number.1
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3____14
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.9
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.2
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3____14
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.7
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.0
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3____14
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.7
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.9
đầu ra
Enter the numbers A, B and C: 2 8 1 8 is the largest number.
Độ phức tạp về thời gian. O[1] vì nó đang thực hiện các hoạt động liên tục
Không gian phụ trợ. Ô[1]
ví dụ 2. Sử dụng câu lệnh if-else để tìm số lớn nhất.
C
Enter the numbers A, B and C: 2 8 1 8 is the largest number.20
Enter the numbers A, B and C: 2 8 1 8 is the largest number.21
Enter the numbers A, B and C: 2 8 1 8 is the largest number.22
Enter the numbers A, B and C: 2 8 1 8 is the largest number.23
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.21
Enter the numbers A, B and C: 2 8 1 8 is the largest number.1
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.210
Enter the numbers A, B and C: 2 8 1 8 is the largest number.6
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.0
Enter the numbers A, B and C: 2 8 1 8 is the largest number.1
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.219
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.222
Enter the numbers A, B and C: 2 8 1 8 is the largest number.223
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.9
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.229
Enter the numbers A, B and C: 2 8 1 8 is the largest number.223
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.9
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.229
Enter the numbers A, B and C: 2 8 1 8 is the largest number.23
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.242
Enter the numbers A, B and C: 2 8 1 8 is the largest number.223
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.7
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.229
Enter the numbers A, B and C: 2 8 1 8 is the largest number.223
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.9
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.7
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.9
đầu ra
Enter the numbers A, B and C: 2 8 1 8 is the largest number.
Độ phức tạp về thời gian. O[1] vì nó đang thực hiện các hoạt động liên tục
Không gian phụ trợ. Ô[1]
ví dụ 3. Sử dụng câu lệnh if-else lồng nhau để tìm số lớn nhất.
C
Enter the numbers A, B and C: 2 8 1 8 is the largest number.20
Enter the numbers A, B and C: 2 8 1 8 is the largest number.21
Enter the numbers A, B and C: 2 8 1 8 is the largest number.22
Enter the numbers A, B and C: 2 8 1 8 is the largest number.23
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.21
Enter the numbers A, B and C: 2 8 1 8 is the largest number.1
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.210
Enter the numbers A, B and C: 2 8 1 8 is the largest number.6
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.0
Enter the numbers A, B and C: 2 8 1 8 is the largest number.1
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3____14
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.9
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.229
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.2
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3____14
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.7
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.229
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3____14
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.5
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.7
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.9
đầu ra
Enter the numbers A, B and C: 2 8 1 8 is the largest number.
Độ phức tạp về thời gian. O[1] vì nó đang thực hiện các hoạt động liên tục
Không gian phụ trợ. Ô[1]
Ví dụ 4. Sử dụng toán tử bậc ba để tìm số lớn nhất.
C
Enter the numbers A, B and C: 2 8 1 8 is the largest number.20
Enter the numbers A, B and C: 2 8 1 8 is the largest number.21
Enter the numbers A, B and C: 2 8 1 8 is the largest number.22
Enter the numbers A, B and C: 2 8 1 8 is the largest number.23
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.21
Enter the numbers A, B and C: 2 8 1 8 is the largest number.62
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.210
Enter the numbers A, B and C: 2 8 1 8 is the largest number.6
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.0
Enter the numbers A, B and C: 2 8 1 8 is the largest number.1
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.74
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.3
Enter the numbers A, B and C: 2 8 1 8 is the largest number.4
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.79
Enter the numbers A, B and C: 2 8 1 8 is the largest number.24
Enter the numbers A, B and C: 2 8 1 8 is the largest number.7
Enter the numbers A, B and C: 2 8 1 8 is the largest number.8
Enter the numbers A, B and C: 2 8 1 8 is the largest number.9
đầu ra
Enter the numbers A, B and C: 2 8 1 8 is the largest number.
Độ phức tạp về thời gian. O[1] vì nó đang thực hiện các hoạt động liên tục
Không gian phụ trợ. Ô[1]
Ghi chú cá nhân của tôi arrow_drop_up
Tiết kiệm