1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

俺用、範囲を判定するマクロ 成功0428

Last updated at Posted at 2025-04-27

いろいろ、注意

  • Arduino UNOでの 予定は、未定
  • いろいろ、あって、完成(朝、ぎりぎり10分前から初めたので、一発で動くと思っていた。)
  • 今回のポイントと、方向によって範囲を反転

プログラム

オンラインコンパイラpaiza



#define RE(A,B,C) (  (A<B)?( (C >= A) && (C <= B) ):( (C >= B) && (C <= A) )  )

#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    
    for(int i=1;i<=7;i++){
        if( RE(3,6,i) ) {
            printf("RE(3,6,%d) YES\n",i);
        }else{
            printf("RE(3,6,%d) NO\n",i);
        }
    }
    printf("\n");
    for(int i=1;i<=7;i++){
        if( RE(6,3,i) ) {
            printf("RE(6,3,%d) YES\n",i);
        }else{
            printf("RE(6,3,%d) NO\n",i);
        }
    }
    
}




RE(3,6,1) NO
RE(3,6,2) NO
RE(3,6,3) YES
RE(3,6,4) YES
RE(3,6,5) YES
RE(3,6,6) YES
RE(3,6,7) NO

RE(6,3,1) NO
RE(6,3,2) NO
RE(6,3,3) YES
RE(6,3,4) YES
RE(6,3,5) YES
RE(6,3,6) YES
RE(6,3,7) NO


1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?