gpt4 book ai didi

c++ - 这有什么问题? C++

转载 作者:行者123 更新时间:2023-11-28 06:41:51 24 4
gpt4 key购买 nike

我正在尝试使用我所了解的 C++ 进行编程练习。它是一个基本的计算器,用于计算我玩的 MMO 的内容。

我想在不使用 system() 命令的情况下清除 cmd 的屏幕。但是在函数中:void clearscreen 第一个花括号在 vs 2013 中给出了一个错误,期望一个 ;

我也知道可能有更好的方法来完成所有这些,但这是我目前所知道的并且只是在练习。我主要想知道这有什么问题,但也非常感谢有关改进此基本程序的反馈

-非逻辑逻辑

#include "stdafx.h"
#include <iostream>
#include <string>
#include <stdio.h>
#include <iomanip>

using namespace std;

int main()
{
double timetotal;
double timeperinv;
double xptotal;
double xpitem;
double amount;
double perinv;
double totalinv;
double costper;
double costtotal;

cout << "=+=+=+=+=+=+=+=Runescape Skill Calculator=+=+=+=+=+=+=+=" << endl;
cout << endl;

cout << "How much experience do you want to get?" << endl;
cin >> xptotal;
cout << endl;

cout << "How much does it cost per item?" << endl;
cin >> costper;
cout << endl;

cout << "How much experience do you get per item?" << endl;
cin >> xpitem;
cout << endl;

cout << "How many items can you process in one inventory?" << endl;
cin >> perinv;
cout << endl;

cout << "How long does it take to process one inventory of items?" << endl;
cin >> timeperinv;

amount = xptotal / xpitem;
totalinv = amount / perinv;
timetotal = totalinv * timeperinv;
costtotal = amount * costper;

void ClearScreen()
{
cout << string(100, '\n');
}

cout << "=+=+=+=+=+=+=+=Runescape Skill Calculator=+=+=+=+=+=+=+=" << endl;
cout << endl;
std::cout << std::setprecision(1) << fixed;
cout << "The amount of items that you will need to process is: \n" << amount << endl;
cout << endl;

cout << "The amount of inventories of items that you will need" << endl;
cout << "to process is \n" << totalinv << endl;
cout << endl;

cout << "The total time it will take to complete processing all" << endl;
cout << "of the items is: \n" << timetotal << endl;
cout << endl;

cout << "The total cost of the items will be: \n" << costtotal << endl;
cout << endl;

cout << "The total amount of inventories to process is: \n" << totalinv << endl;
cout << endl;

}

最佳答案

C++ 不支持内部函数。只需在 main() 之外定义 ClearScreen

关于c++ - 这有什么问题? C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25832711/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com