+ 10

can anybody write a program for #how many numbers of ones in 1 to 100 numbers?

23rd Nov 2017, 10:40 AM
pratap dsp
pratap dsp - avatar
2 ответов
+ 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...!
23rd Nov 2017, 11:13 AM
Dev
Dev - avatar
+ 5
tnquuu 😊
23rd Nov 2017, 12:56 PM
pratap dsp
pratap dsp - avatar