LoginSignup
1

More than 5 years have passed since last update.

【備忘録】C++での判定

Posted at

はじめに

デスクトップが汚くなってきたので整理中。
今回のはどこかの記事のコードを書いたやつ。

備忘録コード

test.cpp
#include <iostream>
#include <cmath>
#include <iomanip>
#include <assert.h>
using namespace std;
int main(){

    long double n;  cin>>n;
    //assert(n==0);// n = 0
    long double l = 18014415152484098.0 + n;

    long double calc = sqrt(l);
    cout<< calc <<endl;

    long double calc2 = sqrt(18014415152484098.0);
    cout << calc2 <<endl;

    if(calc == calc2) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;

    return 0;
}

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1