My opinion on this question is that I cannot use advanced algorithms, that is, the idea is flexible, there are many ideas, and I have learned a lot from it. If this is the first time you read this article, please first read:Views on Baidu developer interview questions for 85% million interviewees eliminatedI also mentioned optimization. Many of my friends always make mistakes in the optimized code. I finally posted the optimized source code. Please referOne Baidu developer interview question (updated) that eliminated 85% million interviewers), I will also mention the classes used for optimization later. Please referStringBuilder and StringBuffer parsing (required for Baidu interview optimization)If you have previously written optimized code, see:Baidu developer interview questions (optimized)Today, we suddenly have another new idea. We only need to make two judgments, but the code is more intuitive. I will not say much about the other. I must have already made it clear before, if you have any questions, please feel free to discuss them ..
Public class Baidu5 {public static void main (String [] args) {StringBuilder result = new StringBuilder (); for (int I = 1; I <= 100; I ++) {result. append (I % 3 = 0? "*": ""); Result. append (I % 5 = 0? "#": ""); System. out. print (result. length ()> 0? I: ""); System. out. println (result); result. setLength (0 );}}}