Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
965 张宸瑞 十进制转二进制 C++ Accepted 0 MS 272 KB 326 2023-06-10 15:07:45

Tests(20/20):


Code:

#include <iostream> #include <string> using namespace std; string s; int main() { char c; int x,i=0,n; cin>>x; while(x!=0){ n=x%2; c=n+'0'; s=c+s; x=x/2; } if(s=="") { cout<<"0"; } else{ cout<<s; } return 0; }