-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6位生成器.cpp
More file actions
99 lines (98 loc) · 3.29 KB
/
6位生成器.cpp
File metadata and controls
99 lines (98 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <iostream>
#include <fstream>
using namespace std;
long long int out(long long int in)
{
int a, b, c, d, e, f;
a = in % 10;
b = (in / 10) % 10;
c = (in / 100) % 10;
d = (in / 1000) % 10;
e = (in / 10000) % 10;
f = (in / 100000) % 10;
ofstream fout("main.cpp", ofstream::app);
fout << " case " << in << ":" << endl;
if (f != 0)
{
fout << " cout<<\"" << in << " 是六位数\"<<endl;" << endl;
fout << " cout<<\"个位是 " << a << " \"<< endl;" << endl;
fout << " cout<<\"十位是 " << b << " \"<< endl;" << endl;
fout << " cout<<\"百位是 " << c << " \"<< endl;" << endl;
fout << " cout<<\"千位是 " << d << " \"<< endl;" << endl;
fout << " cout<<\"万位是 " << e << " \"<< endl;" << endl;
fout << " cout<<\"十万位是 " << f << " \"<< endl;" << endl;
fout << " cout<<\"倒过来是 " << f << e << d << c << b << a << "\"<< endl;" << endl;
fout << " break;" << endl;
return 0;
}
else if (e != 0)
{
fout << " cout<<\"" << in << " 是五位数\"<<endl;" << endl;
fout << " cout<<\"个位是 " << a << " \"<< endl;" << endl;
fout << " cout<<\"十位是 " << b << " \"<< endl;" << endl;
fout << " cout<<\"百位是 " << c << " \"<< endl;" << endl;
fout << " cout<<\"千位是 " << d << " \"<< endl;" << endl;
fout << " cout<<\"万位是 " << e << " \"<< endl;" << endl;
fout << " cout<<\"倒过来是 " << e << d << c << b << a << "\"<< endl;" << endl;
fout << " break;" << endl;
return 0;
}
else if (d != 0)
{
fout << " cout<<\"" << in << " 是四位数\"<<endl;" << endl;
fout << " cout<<\"个位是 " << a << " \"<< endl;" << endl;
fout << " cout<<\"十位是 " << b << " \"<< endl;" << endl;
fout << " cout<<\"百位是 " << c << " \"<< endl;" << endl;
fout << " cout<<\"千位是 " << d << " \"<< endl;" << endl;
fout << " cout<<\"倒过来是 " << d << c << b << a << "\"<< endl;" << endl;
fout << " break;" << endl;
return 0;
}
else if (c != 0)
{
fout << " cout<<\"" << in << " 是三位数\"<<endl;" << endl;
fout << " cout<<\"个位是 " << a << " \"<< endl;" << endl;
fout << " cout<<\"十位是 " << b << " \"<< endl;" << endl;
fout << " cout<<\"百位是 " << c << " \"<< endl;" << endl;
fout << " cout<<\"倒过来是 " << c << b << a << "\"<< endl;" << endl;
fout << " break;" << endl;
return 0;
}
else if (b != 0)
{
fout << " cout<<\"" << in << " 是两位数\"<<endl;" << endl;
fout << " cout<<\"个位是 " << a << " \"<< endl;" << endl;
fout << " cout<<\"十位是 " << b << " \"<< endl;" << endl;
fout << " cout<<\"倒过来是 " << b << a << "\"<< endl;" << endl;
fout << " break;" << endl;
return 0;
}
else
{
fout << " cout<<\"" << in << " 是一位数\"<<endl;" << endl;
fout << " cout<<\"个位是 " << a << " \"<< endl;" << endl;
fout << " break;" << endl;
return 0;
}
}
int main()
{
ofstream fout;
fout.open("main.cpp");
fout << "#include<iostream>" << endl;
fout << "using namespace std;" << endl;
fout << "int main(){" << endl;
fout << " cout << \"请给出一个不多于六位数的正整数:\";" << endl;
fout << " int x;" << endl;
fout << " cin >> x; " << endl;
fout << " switch(x){" << endl;
fout.close();
for (long long int a = 0; a < 1000000; a++)
{
out(a);
}
fout.open("main.cpp", ofstream::app);
fout << " }" << endl
<< "}";
fout.close();
}