小编use*_*229的帖子

C++错误C2040?

错误信息:

这是什么意思?

我该如何解决?

错误C2040:'==':'int'的间接级别与'const char [2]'不同

码:

#include <iostream>
#include <cmath>
using namespace std;

int round(double number);
//Assumes number >=0.
//Returns number rounded to the nearest integer.

int main()
{
    double doubleValue;
    char ans;

    do
    {
        cout << "Enter a double value: ";
        cin >> doubleValue;
        cout << "Rounded that number is " <<round(doubleValue)<< endl;
        cout << "Again? (y/n): ";
        cin >> ans;

    }
    //Here is the line generating the problem, while(...);

    while (ans == 'y' || ans == "Y"); …
Run Code Online (Sandbox Code Playgroud)

c++

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

C++转换不起作用

#include <iostream>
using namespace std;
/*Use void functions, they perform some action but do not return a value*/

//Function Protoype, input,read in feet and inches:
void input (double&  feet, double& inches);
//Function Prototype, calculate, calculate with given formulae.
void calculate(double& feet, double& inches);
//Function Prototype, output, outputs calculations to screen.
void output (double meters, double centimeters);  

int main () 
{
    double feet;
    double inches;
    char repeat;

    do
    {
        //Call input:
        input(feet, inches);
        //Call calculate:
        calculate(feet, inches);
        //Call output:
        output (feet, …
Run Code Online (Sandbox Code Playgroud)

c++

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

C++,二十个数字不是随机的?

为什么我的C++数字不是随机的?

#include <iostream>
#include <cstdlib>
using namespace std;


int main()
{
    int randomNumber = rand() % 100;


    for (randomNumber = 0; randomNumber < 20; randomNumber++)
    {

        cout << randomNumber << endl;
    }
    return 0;
}

//Why are my 20 numbers not random?
Run Code Online (Sandbox Code Playgroud)

c++ random

-6
推荐指数
1
解决办法
591
查看次数

标签 统计

c++ ×3

random ×1