2017-06-17から1日間の記事一覧
整数 x を n 進数で表記するプログラム #include <stdio.h> #include <math.h> int convert(int x, int n){ int y=0, i=0, z; while(x > 0){ z = x%n; y += z*pow(10, i); x = x/n; i++; } return y; } int main(void){ printf("%d\n", convert(5, 2)); } アルゴリズム解説 x</math.h></stdio.h>…