1357 [Ba1000] Simple C++ Program
来源:互联网 发布:app提示网络连接失败 编辑:程序博客网 时间:2024/06/05 15:28
Description
C++的输入输出使用cin 和cout函数,这两个函数存在于<iostream>
头文件中。
在C语言中,输出和输出一般需要指明变量的类型,而在C++中,输入和输出无须指明变量的类型。eg:
int number1;float number2;char x;scanf("%d%f%c", &number1, &number2, &x);
以上的C语言程序在C++中为
#include <iostream> // 包含输入输出函数的头文件using namespace std; // 命名空间,详细含义在以后了解,如果不加这一句,cin会报错int number1;float number2;char x;cin >> number >> number2 >> x;
如果在上面的程序中不加上* using namespace std; *,则需要改为std::cin >> number >> number2 >> x;
输出:
#include <iostream>std::cout << "hello world!" << std::endl; // endl == '\n'
请使用C++的输入输出进行练习。
Input
int a, b;double d_x, d_y;char arr[10][11];
Output
a的b次方(用pow()函数,头文件cmath)
d_x*d_y
数组从最后一行到第一行的输出
Simple Input
2 3
3.14 4.25
0000000000
1111111111
2222222222
3333333333
4444444444
5555555555
6666666666
7777777777
8888888888
9999999999
Simple Output
8
13.345
9999999999
8888888888
7777777777
6666666666
5555555555
4444444444
3333333333
2222222222
1111111111
0000000000
Submission
answer.cpp
#include<iostream>#include<cmath>using namespace std;int main(){ int a, b; double d_x, d_y; char arr[10][11]; cin>>a>>b>>d_x>>d_y; for(int i=0;i<10;i++){ cin>>arr[i]; } cout<<pow(a,b)<<endl<<d_x*d_y<<endl; for(int i=9;i>=0;i--){ cout<<arr[i]<<endl; } return 0;}
Standard Answer
answer.cpp
#include <iostream>#include <cmath>using namespace std;int main() { int a, b; double d_x, d_y; char arr[10][11]; cin >> a >> b >> d_x >> d_y; for (int i = 0; i < 10; ++i) { cin >> arr[i]; } cout << pow(a, b) << endl; cout << d_x*d_y << endl; for (int i = 9; i >= 0; --i) { cout << arr[i] << endl; } return 0;}
阅读全文
0 0
- 1357 [Ba1000] Simple C++ Program
- Some simple c program
- [C]: make program simple - No.1
- [C]: make program simple - No.2
- A Simple Java Program
- A simple XDR program
- Simple audio recording program
- [java] a simple Applet program
- Writing a simple C++ Program
- C++ - A Simple Calculator Program
- A simple libpng example program
- How to Debug C Program using gdb in 6 Simple Steps
- Mac OS 安装tensorflow RuntimeError: Broken toolchain: cannot link a simple C program
- c program
- cmake编译ITK报错:The C compiler is not able to compile a simple test program
- Running a simple program for MSVC++
- A simple client/server communication program
- Simple "virus" like program in C++
- C++搜索与回溯算法之拆数
- HDU2767 Proving Equivalences
- Magento 2中文手册教程
- JAVA位运算
- Android动态申请权限
- 1357 [Ba1000] Simple C++ Program
- SAP HANA Odata的POST报错404 resource not found
- Linux源码安装LNMP
- uva 227 Puzzle
- (154)光照通道
- 算法训练:Triangle
- 硬件访问服务3之Android程序操作LED_P
- Flask +jinja2+bootstrap+sqlite3+sqlalchemy构建web基础学习总结
- SAP HANA Odata的POST报错400 Bad Request Error