Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;嵌套循环,以幂递增基数_C++_Nested Loops_Long Integer - Fatal编程技术网

C++ C++;嵌套循环,以幂递增基数

C++ C++;嵌套循环,以幂递增基数,c++,nested-loops,long-integer,C++,Nested Loops,Long Integer,我需要一些帮助。我想达到我的图像上显示的结果 第一个问题。。。我的老师犯了错误吗?2^10=1024而不是2048?!但是nvm 我唯一的问题是数字超过10万-请帮助 这是到目前为止我的代码 #include <iostream> #include <math.h> #include <iomanip> #include <string> #include <sstream> #include <ostream> #incl

我需要一些帮助。我想达到我的图像上显示的结果

第一个问题。。。我的老师犯了错误吗?2^10=1024而不是2048?!但是nvm

我唯一的问题是数字超过10万-请帮助

这是到目前为止我的代码

#include <iostream>
#include <math.h>
#include <iomanip>
#include <string>
#include <sstream>
#include <ostream>
#include <stdio.h>
#include <conio.h>
#include <fstream>

using namespace std;

int main() {
    int p;      // exponent
    float b;    // base

    cout << setw(4);
    for (b=1; b<11; b++) {
        cout << " | " << setw(12) << b;
    }
    cout << endl;
    for (b=1; b<=10; b++) {
        cout << b;  
        for (p=1; p<=10; p++) {
            cout << " | " << setw(12) << pow(b, p);
        }
        cout << endl;
    }
    return 0;
}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
int main(){
int p;//指数
浮点b;//基

cout如果问题是输出,那么最简单的方法是将
pow()
返回值强制转换为
long
或编译器的64位
int
类型


<>这将自动使用<代码>长代码>代码>过载>代码>操作员哦…………可以告诉我包含的内容吗?我不需要这个。我只是从教程中添加了一些我看的……我说,我是C++新手,通常我是一个网页设计师——所以没有太多的编程:/@ Rellston,数字没有错。用科学记数法重新编写。这就是问题所在吗?第一个表的第二行似乎是错误的(假设您想要第^col行),因为第2^3=8而不是第16行(因此实际上该行的其余部分应该向右移动,并以第2^10=1024行结束)。谢谢你的快速回复!我的数字有什么问题吗?在我的输出图像中,你可以看到10^10=1e+010,而不是我预期的:1000000000!@Rellston你知道1e+010是1000000000,对吧?是格式问题,而不是结果问题。是的,只有输出问题:D非常感谢-现在工作非常好!!!@PaulMcKenzie
 for (p=1; p<=10; p++) {
    cout << " | " << static_cast<long long>(pow(b, p));