Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 3:1883ea70d247
- Parent:
- 2:98f6cc48ca3a
- Child:
- 4:9fefb9f18f08
--- a/main.cpp Fri Dec 11 06:47:03 2020 +0000
+++ b/main.cpp Wed Dec 23 06:51:02 2020 +0000
@@ -2,23 +2,34 @@
Serial pc(SERIAL_TX, SERIAL_RX);
Serial device(PA_9,PA_10);
-int main()
+
+int main(void)
{
-
- while(1) {
- char c = device.getc();
-
- if(c == 0x7A) {
- pc.printf("%02hhx \n",c);
- if(device.getc() == 0x7A) {
- pc.printf("%02hhx \n",c);
-
- } else if(c == 0x79) {
- pc.printf("%02hhx \n",c);
- }
- }
+ /* 変数の宣言 */
+ int i;
+ int decimal = 14;
+ int binary[7]={0};
+
+ /* 10進数の入力
+ printf("10進数 = ");
+ scanf("%d", &decimal);*/
+
+ /* 10進数→2進数の変換 */
+ for(i=0;decimal>0;i++){
+ binary[i] = decimal % 2;
+ decimal = decimal / 2;
+ }
+
+ /* 2進数の出力 */
+ printf(" 2進数 = ");
+ int k = 8;
+ while( k>0 ){
+ printf("%d", binary[--k]);
+ }
+ printf("\n");
+
+ return 0;
}
-
\ No newline at end of file