我正在使用我所知道的C ++实践编程。它是我玩游戏MMO的基本计算器。
我想在不使用system()命令的情况下清除cmd的屏幕。但是在函数中:void clearscreen第一个花括号在vs 2013中给出了一个错误,期待a;
此外,我知道可能有更好的方法来完成所有这些,但这是我目前所知道的,我只是在练习。我主要想知道这有什么问题,但是对于改进这个基本程序的反馈也将非常感激
-Unlogical Logic
#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;
}
答案 0 :(得分:1)
C ++不支持内部功能。只需在ClearScreen
和 之前定义main()
。