Seventh Week task 24 number maximum

Source: Internet
Author: User

/*
* Copyright (c) 2011, Yantai University School of Computer Science
* All rights reserved.
* Author: Tian Yu
* Completion Date: October 11, 2012
* Version Number: v1.0
*
* Enter a description: four positive integers
* Problem Description: Given four positive integers, the maximum value of four numbers is calculated and output
* Program output: The maximum value of a given four number
* Problem Analysis: By comparing two numbers, the large assignment is given to the small one, and then the maximum value is compared.
* Algorithm design: slightly

#include <iostream>  
using namespace std;  
int main ()  
{  
    int a,b,c,d;  
    cout<< "Please enter the value of the A,b,c,d four number:";  
    cin>>a>>b>>c>>d;  
    {  
        if (a<b)  
        a=b;       
        if (c<d)  
        C=d;        
        if (a>c)  
            cout<< "max=" <<a<< "\ n";  
        else
            cout<< "max=" <<c<< "\ n";  
    }  
    return 0;  


Operation Result:

Experience:

Homework 2 Turn relatively slow, change and change, get oneself think of the simplest to turn, programming is not simple and clear, the best at a glance understand .... Come on....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.