#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
ifstream infile("salary.txt",ios::in);
if(!infile)
{
cerr << "open error!";
exit(0);
}
double a[500], t;
int i, j;
for(i = 0; i < 500; ++ i)
{
infile >> a[i];
a[i] = a[i] + 100;
}
infile.close();
for(j = 0; j <499 ;++ j)
{
for(i = 0; i < 499 - j; ++ i)
{
if(a[i] < a[i + 1])
{
t = a[i];
a[i] = a[i + 1];
a[i + 1] = t;
}
}
}
ofstream outfile("ordered_salary.txt",ios::out);
if(!outfile)
{
cerr << "open error!";
exit(0);
}
cout << "涨工资后的工资为:" << endl;
for(i = 0; i < 500; ++ i)
{
outfile << a[i] << " ";
}
for(i = 0; i < 500; ++ i)
{
cout<< a[i] << " ";
if(((i + 1) % 9) == 0)
{
cout << endl;
}
}
system("pause");
return 0;
}
涨工资后的工资为:
3085.84 3084.95 3082.7 3081.5 3068.97 3062.72 3058.93 3058.17 3047.4
3045.1 3040.78 3034.8 3030.51 3019.21 3014.69 3012.41 3009.22 3006.9
3006.75 3005.76 3004.98 2990.26 2986.68 2985.38 2979.14 2975.25 2974.9
2961.65 2957.6 2954.6 2951.86 2946.23 2941.68 2939.73 2938.8 2936.7
2935.94 2932.47 2931.31 2927.11 2922.33 2916.2 2915.13 2914.89 2909.5
2909.58 2898.32 2892.31 2887.2 2877.54 2873.98 2872.85 2872.59 2867.9
2845.52 2843.18 2841.95 2839.34 2838.9 2835.2 2817.51 2816.12 2814.8
2811.12 2809.33 2808.74 2805.8 2804.35 2802.7 2800.53 2773.31 2769.5
2766.2 2756 2750.92 2748.55 2741.32 2740.22 2738.86 2729.71 2727.6
2727.47 2726.1 2720.87 2720.15 2707.83 2700.42 2680.97 2664.65 2660.7
2654.82 2651.5 2650.13 2644.43 2640.76 2638.14 2636.18 2630.81 2621.7
2620.23 2613.58 2607.35 2604.25 2597.9 2595.5 2591.6 2587.88 2578.7
2557.61 2550.49 2546.31 2541.1 2539.71 2534.72 2534.65 2524.46 2516.1
2510.92 2509.58 2500.2 2498.59 2491 2490.4 2486.22 2484.95 2483.7
2476.48 2475.89 2469.1 2460.12 2459.4 2459.26 2449.14 2446.91 2444.9
2441.73 2440.57 2434.86 2425.6 2410.37 2408.74 2406 2392.62 2392.4
2377.5 2365.7 2358.94 2352.79 2349.5 2340.99 2333.84 2326.63 2321.7
2311.9 2306.63 2303.48 2294.15 2292.81 2287.4 2283.8 2278.65 2270.7
2262.98 2261.6 2258.61 2252.61 2252.35 2249.21 2245.99 2245.54 2245.1
2244.4 2243.46 2238.85 2224.58 2221.39 2218.2 2212.3 2206.57 2202.6
2202.52 2192.66 2185.27 2184.51 2180.98 2171.62 2165.6 2152.36 2148.9
2147.84 2141.49 2137.31 2129.45 2127.8 2126.19 2119.3 2111.1 2109.4
2101.91 2090.59 2090.25 2084.87 2080.74 2074.22 2071.24 2055.57 2052.9
2046.68 2046.62 2042.62 2039.63 2038.33 2034.49 2006.4 2004.86 2004.5
2003.66 2000.84 2000.77 1995.55 1993.97 1992.87 1987.33 1986.9 1986.4
1985.23 1974.49 1972.97 1970.13 1969.9 1964.86 1954.94 1948.92 1948.4
1943.52 1942.54 1935.38 1926.21 1922.32 1921.47 1910.68 1910.6 1900.5
1895.2 1892.99 1884.22 1882.77 1868.74 1865.32 1863.34 1860.89 1860.4
1855.86 1848.4 1841.93 1829.38 1818.82 1811.96 1807.79 1807.64 1796.3
1788.42 1787.41 1780.9 1779.8 1775.24 1764.4 1763.38 1759.35 1758.9
1752.41 1748.4 1746.94 1746.79 1741.16 1739.24 1738.25 1736.8 1728.1
1721.71 1713.66 1708.76 1708.52 1705.55 1704.15 1699.24 1697.74 1691.7
1679.13 1678.49 1676.12 1668.5 1664.16 1662.86 1658.9 1629.37 1629.1
1625.74 1622.4 1615.47 1606.61 1596.64 1595.6 1589.57 1588.51 1559.2
1557.61 1549.49 1546.58 1540.24 1532.14 1523.2 1504.53 1501.49 1499.3
1487.96 1485.12 1460.18 1458.76 1449.45 1448.9 1446.39 1436.68 1432.4
1429.64 1427.6 1426.63 1426.54 1424.28 1413.75 1411.32 1409.49 1406.8
1398.99 1397.42 1396.38 1390.2 1387.69 1380.23 1368.82 1367.37 1365.4
1354.64 1354.24 1345.72 1339.96 1336.46 1331.82 1331.26 1328.94 1328
1322.8 1320.87 1313.95 1307.1 1299.42 1297.41 1294.94 1294.8 1294.6
1290.11 1287.33 1281.16 1280.6 1270.91 1268.84 1266.78 1263.87 1247.8
1245.34 1245.24 1243.64 1236.91 1232.66 1219.57 1218.11 1215.63 1215.5
1215.36 1212.86 1203.17 1199.51 1191.78 1191.62 1182.87 1172.8 1169.9
1168.69 1166.63 1161.66 1150.54 1145.9 1134.7 1126.28 1124.76 1113.8
1111.89 1106.2 1105.74 1105.61 1105.34 1103.43 1103.34 1098.22 1093.8
1085.94 1080.55 1078.89 1075.23 1072.92 1072.81 1062.57 1062.4 1062.1
1055.71 1055.17 1050.45 1049.99 1040.34 1038.28 1028.37 1009.68 1009.4
1006.43 1002.29 1001.26 999.71 997.91 995.16 981.12 976.95 972.61
964.92 962.85 962.48 962.27 958.74 953.4 951.57 950.81 950.4
945.14 944.49 933.42 932.11 931.39 931.11 928.64 925.9 917.2
904.2 902.77 892.32 891.95 882.3 879.92 878.31 873.56 871.3
863.77 857.65 848.5 846.5 841.9 829.15 828.13 823.49 810.45
805.92 799.68 795.48 794.8 788.48 781.29 780.8 778.67 766.83
748.86 743.84 740.75 734.22 722.48 719.54 714.22 713.3 711.29
699.77 696.16 692.22 689.97 689.43 685.25 673.1 672.72 660.24
654.3 653.65 648.71 644.67 634.43 请按任意键继续. . .
感悟:
ifstream infile("salary.txt",ios::in);书上还有一部分但是加上以后出现错误,求解释