读入写出,转二进制

#include <bits/stdc++.h>
using namespace std;
int main(){
	freopen("mz.txt","r",stdin);
	freopen("out.txt","w",stdout);
	string n;
	int a=0,m[7],j;
	cin>>n;
	for(int i=0;i<n.size();i++){
		a=n[i];
		for(j=0;a!=0;j++){
			m[j]=a%2;
			a/=2;
		}
		for(int k=j-1;k>=0;k--){
			cout<<m[k];
		}
	}	
	return 0;
}

  

posted @ 2024-07-29 15:01  fushuxuan1  阅读(2)  评论(0编辑  收藏  举报