Tedd OKANO
/
RPN_calc__based_on_K_and_R
just a sample of what can be done
PRN電卓プログラム
「プログラミング言語C (K&R本)」に出てくる例を元にした,RPN計算機です.
写真はイメージです
このプログラムは..
- 『mbed祭り 2015@初夏の東銀座』の親睦会で「RPN」と題して行ったLT(LightningTalk)でのデモ・プログラムです.
- mbed LPC1768,mbed LPC1114FN28で実行できることを確認しています(たぶん他のプラットフォームでも動きます)
- プレゼンスライドを置いておきます
getop.cpp
- Committer:
- okano
- Date:
- 2015-06-27
- Revision:
- 5:3b9daee5f734
- Parent:
- 3:4ef74510cc5b
File content as of revision 5:3b9daee5f734:
#include "mbed.h" #include "calc.h" #include <ctype.h> int getop( char s[] ) { int i, c; while ( (s[ 0 ] = c = getch()) == ' ' || c == '\t' ) ; s[ 1 ] = '\0'; if ( !isdigit( c ) && c != '.' ) return c; i = 0; if ( isdigit( c ) ) while ( isdigit( s[ ++i ] = c = getch() ) ) ; if ( c == '.' ) while ( isdigit( s[ ++i ] = c = getch() ) ) ; s[ i ] = '\0'; if ( c != EOF ) ungetch( c ); return NUMBER; }