插入代码试一试

插入代码试一试

#include <iostream>
int main()
{
    // local objects of type int
    int value = 2;
    int pow = 10;
    int result = 1;

    // repeat calculation of result until cnt is equal to pow
    for (int cnt = 0; cnt != pow; ++cnt)
        result *= value;   // result = result * value;

    std::cout << value 
              << " raised to the power of "
              << pow << ": \t"
              << result << std::endl;
    return 0;
}

 

 1 #include <iostream>
 2 int main()
 3 {
 4     // local objects of type int
 5     int value = 2;
 6     int pow = 10;
 7     int result = 1;
 8 
 9     // repeat calculation of result until cnt is equal to pow
10     for (int cnt = 0; cnt != pow; ++cnt)
11         result *= value;   // result = result * value;
12 
13     std::cout << value 
14               << " raised to the power of "
15               << pow << ": \t"
16               << result << std::endl;
17     return 0;
18 }
posted @ 2012-08-05 19:55  cosmicy  阅读(157)  评论(1)    收藏  举报