just a sample of what can be done

Dependencies:   mbed

PRN電卓プログラム

「プログラミング言語C (K&R本)」に出てくる例を元にした,RPN計算機です.

hp写真はイメージです

このプログラムは..

Committer:
okano
Date:
Sat Jun 27 01:29:21 2015 +0000
Revision:
5:3b9daee5f734
Parent:
3:4ef74510cc5b
functions "power" and "drop" are added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 2:0e96f4495b43 1 #include "mbed.h"
okano 2:0e96f4495b43 2 #include "calc.h"
okano 2:0e96f4495b43 3 #include <ctype.h>
okano 2:0e96f4495b43 4
okano 2:0e96f4495b43 5 int getop( char s[] )
okano 2:0e96f4495b43 6 {
okano 2:0e96f4495b43 7 int i, c;
okano 2:0e96f4495b43 8
okano 2:0e96f4495b43 9 while ( (s[ 0 ] = c = getch()) == ' ' || c == '\t' )
okano 2:0e96f4495b43 10 ;
okano 2:0e96f4495b43 11
okano 2:0e96f4495b43 12 s[ 1 ] = '\0';
okano 2:0e96f4495b43 13
okano 2:0e96f4495b43 14 if ( !isdigit( c ) && c != '.' )
okano 2:0e96f4495b43 15 return c;
okano 2:0e96f4495b43 16
okano 2:0e96f4495b43 17 i = 0;
okano 2:0e96f4495b43 18
okano 2:0e96f4495b43 19 if ( isdigit( c ) )
okano 2:0e96f4495b43 20 while ( isdigit( s[ ++i ] = c = getch() ) )
okano 2:0e96f4495b43 21 ;
okano 2:0e96f4495b43 22
okano 2:0e96f4495b43 23 if ( c == '.' )
okano 2:0e96f4495b43 24 while ( isdigit( s[ ++i ] = c = getch() ) )
okano 2:0e96f4495b43 25 ;
okano 2:0e96f4495b43 26
okano 2:0e96f4495b43 27 s[ i ] = '\0';
okano 2:0e96f4495b43 28
okano 2:0e96f4495b43 29
okano 2:0e96f4495b43 30 if ( c != EOF )
okano 2:0e96f4495b43 31 ungetch( c );
okano 2:0e96f4495b43 32
okano 2:0e96f4495b43 33 return NUMBER;
okano 2:0e96f4495b43 34 }