(1´Ü°è)
'input()'ÇÔ¼ö·Î ±¸ºÐ
|
(2´Ü°è)
'output()'ÇÔ¼ö·Î ±¸ºÐ
|
|
#include<stdio.h>
int a,i;
int dd[100]={0,};
int input()
{
FILE *ifp=fopen("input.txt","r");
int d;
fscanf(ifp,"%d",&d);
a = d;
fclose(ifp);
return -1;
}
int output()
{
int n;
FILE *ofp=fopen("output.txt", "w");
while(a != 0){
n = a % 2;
a = a / 2;
i = i+1;
dd[i] = n;
}
while(i != 0){
fprintf(ofp, "%d", dd[i]);
i--;
}
fclose(ofp);
return -1;
}
int main()
{
input();
output();
return -1;
}
|
|
º¯¼ö a¿Í º¯¼ö i ±×¸®°í dd[]¹è¿Àº Àü¿ªº¯¼ö·Î ¼±¾ðÇØ¾ß ÇÕ´Ï´Ù.
|
ÀÔ·ÂÆÄÀÏ('input.txt')¿¡¼ Ãâ·ÂÇÒ ½ÊÁø¼ö(d)À» ÀÔ·Â¹Þ¾Æ º¯¼ö'a'¿¡ ¿Å±ä´Ù.
|
10Áø¼ö¸¦ 2Áø¼ö·Î º¯È¯ÇÏ¿© Ãâ·ÂÆÄÀÏ('output.txt')¿¡ Ãâ·ÂÇÑ´Ù.
|
main()ÇÔ¼ö¿¡¼ ´Ù¸¥ÇÔ¼ö¸¦ call Çϰí ÀÖ½À´Ï´Ù
|
|