【摸鱼】光速整活
起因
群里吹水
开始整活
import java.io.*;
/**
* @author LLaamar
* @date 2021/10/20 9:45
*/
public class EightHundredAndEightyThousand {
public static void main(String[] args) throws IOException {
m1();
}
private static void m1() throws IOException {
File file = new File("C:\\Users\\18196\\Desktop\\bolg\\源.cpp");
if (!file.exists()){
file.createNewFile();
}
BufferedWriter br = new BufferedWriter(new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(file))));
String[] strArr = {"个","十","百","千","万"};
// 正序输出字符
char[] charArr;
// 翻转输出用的字符数组
char[] reverse;
StringBuilder sb = new StringBuilder();
sb.append("#include <iostream>").append("\n");
sb.append("using namespace std").append("\n");
sb.append("int main()").append("\n");
sb.append("{").append("\n");
sb.append("\t").append("cout << \"请给出一个不多于5位的正整数:\";").append("\n");
sb.append("\t").append("int x;").append("\n");
sb.append("\t").append("cin >> x;").append("\n");
sb.append("\n");
sb.append("\t").append("switch(x)").append("\t").append("{").append("\n");
String tab = "\t\t";
for (int i = 1; i <= 99999; i++) {
sb.append("\t").append("case").append(" ").append(i).append(":").append("\n");
charArr = (i + "").toCharArray();
reverse = new char[charArr.length];
sb.append(tab).append("cout << ").append("\"是").append(charArr.length).append("位数\"").append(" << endl;").append("\n");
for (int j = 0; j < charArr.length; j++) {
sb.append(tab).append("cout << ").append("\"").append(strArr[j]).append("位数是: ").append(charArr[j]).append("\"").append(" << endl;").append("\n");
reverse[reverse.length - 1 - j] = charArr[j];
}
sb.append(tab).append("cout << ").append("\"倒过来是: ").append(reverse).append("\"").append(" << endl;").append("\n");
sb.append(tab).append("break;").append("\n");
}
sb.append("\t").append("}").append("\n");
sb.append("}");
br.write(sb.toString());
br.flush();
}
}
结果
结束语
感兴趣的可以拿代码到Java环境跑一下,不说一模一样,也算八九不离十。
那就这样吧,加内。
你字符串忘记加引号了。
细啊,已经加上了
好家伙,这就整上了,真的是闲的
牛皮
整挺好~