从in.in文件读取两个整数,第一个是要转换的数,第二个是进制数
将结果输出到out.out里面去,(在一行内)从前到后是转换后各个位数上的数字(用空格分开)
13 2
1 1 0 1
我曾经尝试过,但是不成功,还请各位蒟蒻多多请教
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
FILE *fp,*tp; int a,b,c;
if ( fp=fopen("in.in","r") ) {
if ( tp=fopen("out.out","w+") ) {
while ( !feof(fp) ) {
if ( fscanf(fp,"%d",&a)==1 ) {
c=1;
b=0;
while(a){
b+=a%10*c; a/=10; c*=2;
}
fprintf(tp,"%d ",b);
}
}
fclose(tp);
} printf("Can't Out out.out'\n");
fclose(fp);
}
else printf("Can't Open in.in'\n");
return 0;
}
5 2
呜呜呜,快来人帮帮我撒