Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
108111 杜奕辰 十进制转二进制 C++ Compile Error 0 MS 0 KB 950 2025-01-19 14:30:28

Tests(0/0):


Code:

#include<bits/stdc++.h> using namespace std; int y[32];//数组用来倒序 int cut = 0;//累加器 int main() { int n,yu; cin >> n; if(n==0){//因为0的2进制等于0,所以只接输出 cout<<"0"; return 0; } while(n != 0) {//除二取余,终止条件为商(n)等于0 yu = n % 2;//算出余数 y[cut] = yu;//装入数组 cut++; n = n / 2; } for(int i = cut-1; i >= 0; i--) { //倒序输出 cout << y[i]; } return 0; } #include<bits/stdc++.h> using namespace std; int y[32];//数组用来倒序 int cut = 0;//累加器 int main() { int n,yu; cin >> n; if(n==0){//因为0的2进制等于0,所以只接输出 cout<<"0"; return 0; } while(n != 0) {//除二取余,终止条件为商(n)等于0 yu = n % 2;//算出余数 y[cut] = yu;//装入数组 cut++; n = n / 2; } for(int i = cut-1; i >= 0; i--) { //倒序输出 cout << y[i]; } return 0; }


Run Info:

Main.cc:25:9: error: redefinition of 'int y [32]'
 int y[32];//数组用来倒序
         ^
Main.cc:3:5: note: 'int y [32]' previously declared here
 int y[32];//数组用来倒序
     ^
Main.cc:26:5: error: redefinition of 'int cut'
 int cut = 0;//累加器
     ^
Main.cc:4:5: note: 'int cut' previously defined here
 int cut = 0;//累加器
     ^
Main.cc: In function 'int main()':
Main.cc:27:5: error: redefinition of 'int main()'
 int main() {
     ^
Main.cc:5:5: note: 'int main()' previously defined here
 int main() {
     ^