【发布时间】:2010-02-21 22:51:36
【问题描述】:
如果我有一个只有“A”的输入文本,并且我想要一系列代码来生成下一个 ASCII 集 (B),我该怎么做?
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
#include iostream>
#include fstream>
#include iomanip>
#include string>
using namespace std;
int main()
{
ifstream inFile;
ofstream outFile;
string firstName;
string lastName;
string character;
int age;
double rectangle, length, width, area, parameter, circle, radius, areaCircle, circumference, beginningBalance, interestRate, endBalance;
inFile.open("inData.txt");
outFile.open("outData.txt");
outFile << fixed << showpoint;
outFile << setprecision(2);
cout << "Data is processing..." << endl;
inFile >> length >> width;
area = length * width;
parameter = (length * 2) + (width *2);
outFile << "Rectangle:" << endl;
outFile << "Length = " << length << " " << "width = " << width << " " << "area = " << area << " " << "parameter = " << parameter << endl;
inFile >> radius;
outFile << " " << endl;
outFile << "Cricle:" <<endl;
areaCircle = 3.14159 * (radius * radius);
circumference = 2 * (3.14159 * radius);
outFile << "Radius = " << radius << " " << "area = " << areaCircle << " " << "circumference = " << circumference;
outFile << endl;
outFile << endl;
inFile >> firstName >> lastName >> age;
outFile << "Name: " << firstName << " " << lastName << "," << " " << "age: " << age;
outFile << endl;
inFile >> beginningBalance >> interestRate;
outFile << "Beginning balance = " << beginningBalance << "," << " " << "interest rate = " << interestRate << endl;
endBalance = ((18500 * .0350) / 12.0 ) + 18500;
outFile << "Balance at the end of the month = $" << endBalance;
outFile << endl;
inFile >> character;
outFile << "The character that comes after" << character << "in the ASCII set is" << character +1;
inFile.close();
outFile.close();
return 0;
}
【问题讨论】:
-
请不要使用“char”作为变量名。这是一个关键字。
-
要格式化代码,选择它并使用带有 101010 模式的按钮。如果您只想格式化
this这样的句子中的一个块,请使用单反引号。