-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8位生成器.cpp
130 lines (129 loc) · 4.75 KB
/
8位生成器.cpp
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include <iostream>
#include <fstream>
using namespace std;
long long int out(long long int in)
{
int a, b, c, d, e, f, g, h;
a = in % 10;
b = (in / 10) % 10;
c = (in / 100) % 10;
d = (in / 1000) % 10;
e = (in / 10000) % 10;
f = (in / 100000) % 10;
g = (in / 1000000) % 10;
h = (in / 10000000) % 10;
ofstream fout("main.cpp", ofstream::app);
fout << " case " << in << ":" << endl;
if (h != 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<<\"百万位是 " << g << " \"<< endl;" << endl;
fout << " cout<<\"千万位是 " << h << " \"<< endl;" << endl;
fout << " cout<<\"倒过来是 " << h << g << f << e << d << c << b << a << "\"<< endl;" << endl;
fout << " break;" << endl;
return 0;
}
else if (g != 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<<\"百万位是 " << g << " \"<< endl;" << endl;
fout << " cout<<\"倒过来是 " << g << f << e << d << c << b << a << "\"<< endl;" << endl;
fout << " break;" << endl;
return 0;
}
else 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 < 100000000; a++)
{
out(a);
}
fout.open("main.cpp", ofstream::app);
fout << " }" << endl
<< "}";
fout.close();
}