+ 10
can anybody write a program for #how many numbers of ones in 1 to 100 numbers?
2 odpowiedzi
+ 9
CharSequence cs = "1";
int count = 0;
for(int i = 1; i <= 100; i++) {
String str = Integer.toString(i);
if(str.contains(cs)) {
count++;
}
}
System.out.print(count);
// In Java, little easy way...!
+ 5
tnquuu 😊