java
(练习用)挑7
http://www.nowcoder.com/questionTerminal/ba241b85371c409ea01ac0aa1a8d957b
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int n = sc.nextInt(); String str; int count = 0; //i = 0开始0也会算,就多了一个 for(int i = 1; i <= n; i++){ str = String.valueOf(i); if(str.contains("7") || i % 7 == 0){ count++; } } System.out.println(count); } sc.close(); } }