小编Sam*_*Sam的帖子

一个c ++程序在两个IDE中返回不同的结果

我写了下面的c++程序CodeBlocks,结果是9183.我再次写入Eclipse和运行后,它返回9220.两者都使用MinGW.正确的结果是9183.这段代码出了什么问题?谢谢.源代码:

#include <iostream>
#include <set>
#include <cmath>

int main()
{
   using namespace std;
   set<double> set_1;
   for(int a = 2; a <= 100; a++)
   {
       for(int b = 2; b <= 100; b++)
       {
           set_1.insert(pow(double(a), b));
       }
   }
    cout << set_1.size();

return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ eclipse gcc codeblocks

15
推荐指数
1
解决办法
505
查看次数

vim没有突出显示一些c ++关键字

我使用vim(安装cygwin)来编写c++程序,但它并不突出一些c++关键字,如new,delete,public,friend,try,但强调其他如namespace,int,const,operator,true,class,include.它也不会改变运营商的颜色.

我从未改变过它的语法文件.它出什么问题了?非常感谢.

我使用定制的配色方案; 当我将其更改为desert配色方案时,突出显示没有问题,但我需要使用该配色方案,并且无法将其更改为其他内容.

我希望它显示程序如下图(我在图片中使用了带有notepad ++的配色方案):

正确着色的例子

但现在它如下图所示: 没有正确着色的

colorscheme这里:

"Tomorrow Night Bright - Full Colour and 256 Colour
" http://chriskempson.com
"
" Hex colour conversion functions borrowed from the theme "Desert256""

 " Default GUI Colours
 let s:foreground = "eaeaea"
 let s:background = "000000"
 let s:selection …
Run Code Online (Sandbox Code Playgroud)

c++ vi vim syntax-highlighting vim-syntax-highlighting

8
推荐指数
1
解决办法
2441
查看次数

makefile,缺少分隔符错误

我写了一个非常简单makefilec++程序,但它返回makefile:2: *** missing separator. Stop.错误.它出什么问题了?

makefile:

all:
[tab]g++ function.cpp -o out
Run Code Online (Sandbox Code Playgroud)

我在cygwin和中编译程序Ubuntu.

谢谢

c++ cygwin makefile g++

7
推荐指数
2
解决办法
1万
查看次数

c ++添加两个bool数组

我有一个数字作为一个bool数组,但我需要进行算术运算,如加法和减法和逻辑,如AND上面与其他类似的数字.如何在C++中执行此操作而无需处理所有特定于布尔值的计算,并且可以简单地完成.一个例子:

bool a[10];
bool b[10];
bool c[10];
c = a + b; 
Run Code Online (Sandbox Code Playgroud)

c++ boolean

2
推荐指数
1
解决办法
1067
查看次数

php-printf和sprintf具有不同的输出

我编写了以下微型php程序进行测试printfsprintf

<?php
    $str_1 = printf("%x%x%x", 65, 127, 245);
    $str_2 = sprintf("%x%x%x", 65, 127, 245);

    echo $str_1 . "\n";
    echo $str_2 . "\n";
Run Code Online (Sandbox Code Playgroud)

输出是这样的:

417ff56
417ff5
Run Code Online (Sandbox Code Playgroud)

为什么我在输出的第一行中有那个6位数字?

php

2
推荐指数
1
解决办法
313
查看次数

数组未在此范围内声明

我写了一个c ++程序,并在其中使用了array对象和包含<array>头文件,但当我尝试使用g++它编译它时返回很多错误消息,说"数组未在此范围内声明".它可能有什么问题.计划在这里:

#include <iostream>
#include <string>
#include <array>

using namespace std;

const int Seasons = 4;
const array<string, Seasons> Snames =
 {"spring", "summer", "fall", "winter"};

void fill(array<double, Seasons>* pa);
void show(array<double, Seasons> da);

int main()
{
array<double, Seasons> expenses;
fill(&expenses);
show(expenses);

return 0;
}

void fill(array<double, Seasons>* pa)
{
 for(int i = 0; i < Seasons; i++)
 {
    cout << "Enter " << Snames[i] << " expenses: ";
    cin >> *pa[i];
 }
}

void …
Run Code Online (Sandbox Code Playgroud)

c++ g++

0
推荐指数
1
解决办法
9796
查看次数