いろいろ注意
- arduino unoでの予定は、未定
- 乗除算器なしのCPU
目的
主にZ80やPIC等で10進変換
プログラム
オンラインコンパイラ paiza
#include <iostream>
using namespace std;
int main(void){
// Your code here!
int N1000 = 0;
int N100 = 0;
int N10 = 0;
int A = 8951;
//1000
while(A > 999){
A = A - 1000;
N1000 = N1000 + 1;
} //while
//100
while(A > 99){
A = A - 100;
N100 = N100 + 1;
} //while
//10
while(A > 9){
A = A - 10;
N10 = N10 + 1;
} //while
//printf("N1000=%d,N100=%d,N10=%d,A=%d\n",N1000,N100,N10,A);
char str[] = "0000";
str[0] = '0' + N1000;
str[1] = '0' + N100;
str[2] = '0' + N10;
str[3] = '0' + A;
str[4] = 0;
printf(str);
} //main
8951