Daily notes: Log10 functions in C + +

Source: Internet
Author: User

Today, my classmates asked me if there is any simple way to find out the sum of two numbers in C + +, then there is a way to title.

The return value of LOG10 (100) is the return value of 2,log (999) is more, but if you position the return value int, it will automatically convert to 2.

#include<iostream>#include<cmath>usingnamespacestd;int main(){    int a,b;    while(cin>>a>>b){        a=log10(a+b)+1;        cout<<a<<endl;    }        return0;}

For the first time, there are log2 () and other functions, with log10l () and log10f () can also meet different precision.

This does not have to use many for loops to solve, although this article after all simple (after all, water, escape ...) ), but hope to help the novice programming friends.

Extras

Ask for votes or forward support ... I hope I don't die too badly ...

Please click here: Vote

Voting starts from number 10th and continues to number 20th, please!


—————— Of course you can also click on the image directly

Daily notes: Log10 functions in C + +

Related Article

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.