for(n = 0; n < length - 1; n++);
{
if(sbin[n] == '1'){
ctr = ctr + 1;
print(sbin[0]);
}
}
return ('Bit counter - $ctr');
它只显示了sbin的第一个字母。
答案 0 :(得分:1)
main() {
print(someFunction());
}
someFunction() {
var length = 5;
var sbin = ['1', '2', '3', '4', '5'];
var ctr = 0;
for(var n = 0; n < length - 1; n++) {
if(sbin[n] == '1'){
ctr = ctr + 1;
print(sbin[0]);
}
}
return ('Bit counter - $ctr');
}