注册 登录
编程论坛 C++教室

这个是出什么问题了

sunnyzeng 发布于 2019-11-28 22:45, 1837 次点击
//carrots.cpp -- food processing program
//uses and displays a variable

#include <iostream>

int main()
{
    using namespace std;

    int carrots

        carrots = 25
        cout << "I have"
        cout << carrots;
        cout << "carrots.";
        cout << endl;
        carrots = carrots - 1;
        cout << "Crunth,crunth. Now I have " << carrots << "carrots." << endl;
            return 0;
}
2 回复
#2
rjsp2019-11-29 08:42
这个是出什么问题了
别人不愿意猜你想问什么,你有什么问题你要说出来。

比如:
我有如下代码,编译时报错,编译器给的错误信息是:
missing ';' before identifier 'carrots'
missing ';' before identifier 'cout'
missing ';' before identifier 'cout'
只有这样,别人才能知道你想问的是代码的语法错误,才能告诉你解决办法
int carrots
carrots = 25
cout << "I have"
这三句后面缺少分号。
#3
sunnyzeng2019-11-29 22:37
回复 2楼 rjsp
谢谢大佬
1