IO-00~~~IO-04
来源:互联网 发布:如何成为金融数据分析 编辑:程序博客网 时间:2024/05/18 03:16
前几个题目比较简单,我把他们写在一块省的每次都要建立新的博文麻烦
IO-00
#include<iostream>
using std::cout;
int main()
{
cout << "Hello World !";
return 0;
}
IO-01 //我只输出了前两行,因为哪些地名和数字太麻烦,剩下的自己补充就能得到原题的效果
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
char *line = "------------------------------------------------------";
cout << line<<endl;
cout << left;cout << setw(15) << "Province";
cout << right;cout << setw(15) << "Area(km2)" << setw(15) << "Pop(10k)" << endl;
cout << line << endl;
cout << left; cout << setw(15) << "Anhui";
cout << right; cout << setw(15) << "139600.00" << setw(15) << "6461.00" << endl;
cout << left; cout << setw(15) << "Bejing";
cout << right; cout << setw(15) << "16410.54" << setw(15) << "1180.70" << endl;
cout << line << endl;
return 0;
}
IO-02
#include<iostream>
int main()
{
using namespace std;
int a, b;
cout << "Enter two numbers :"<<endl;
if (cin >> a&&cin >> b)
{
cout << a << "+" << b << "=" << a + b << endl;
cout << a << "-" << b << "=" << a - b << endl;
cout << a << "*" << b << "=" << a * b << endl;
cout << a << "/" << b << "=" << a / b << endl;
}
cin.get();
return 0;
}
IO-03
#include<iostream>
#include<iomanip>
int main()
{
using namespace std;
ios_base::fmtflags orig = cout.setf(ios_base::fixed, ios_base::floatfield);
int n = 4; int a[4]; int sum = 0;
cout << "Enter four numbers.\n";
for (int i = 0; i < n; i++)
{
cin >> a[i]; sum += a[i];
}
cout << "Sum = " << sum;
cout.precision(1);
cout<< " ; Average = " << double(sum)/ 4 << endl;
return 0;
}
IO-04
#include<iostream>
int main()
{
using namespace std;
ios_base::fmtflags orig = cout.setf(ios_base::fixed, ios_base::floatfield);
cout.precision(2);
int one; char two; float three; float four;
cout << "Enter four value: float1, int,char,float2\n";
cin >> three;
cin >> one;
cin >> two;
cin >> four;
cout << "Following is output :char,int,float1,float2\n";
cout << two <<" "<< one <<" "<< three <<" "<< four << endl;
return 0;
}
- IO-00~~~IO-04
- IO-00 ---- IO-09
- IO
- IO
- io
- IO
- io
- IO
- io
- IO
- IO
- IO
- io
- IO
- IO
- IO
- IO
- IO
- Openwrt 学习记录:openWRT添加用户模块-helloword(四)
- ECMAScript位运算符
- hdu 1081 To The Max(最大子矩阵和,dp)
- sqlserver 消息 682,: 内部错误。提供用于读取列值的缓冲区太小。请运行 DBCC CHECKDB 查看是否有损坏情况 的处理方法
- 理解 Javascript 的闭包
- IO-00~~~IO-04
- 独处效率感想
- wireshark插件开发详细流程(含源码)
- Linux 日志级别(loglevel)详解
- 学习Javascript闭包(Closure)
- Openwrt 学习记录:openWRT添加内核模块(五)
- 小贝_mysql select5种子句介绍
- leetcode Add and Search Word - Data structure design回溯算法+Trie字典树
- genymotion升级风波-engine not found 及virtual box 的无法打开新任务