ผลต่างระหว่างรุ่นของ "Psl/c++ cheat sheet"
ไปยังการนำทาง
ไปยังการค้นหา
Jittat (คุย | มีส่วนร่วม) |
Jittat (คุย | มีส่วนร่วม) |
||
แถว 2: | แถว 2: | ||
* <tt>int</tt> - for typical 32-bit integers | * <tt>int</tt> - for typical 32-bit integers | ||
− | * <tt>double</tt> - for floating point numbers | + | * <tt>double</tt> - for floating point numbers. Sometimes, it is OK to use <tt>float</tt>, but its precision is usually not enough. |
* <tt>char</tt> - for 1-byte characters | * <tt>char</tt> - for 1-byte characters | ||
* <tt>long long</tt> - for large integers (64 bits) | * <tt>long long</tt> - for large integers (64 bits) |
รุ่นแก้ไขปัจจุบันเมื่อ 23:24, 7 มกราคม 2561
data types
- int - for typical 32-bit integers
- double - for floating point numbers. Sometimes, it is OK to use float, but its precision is usually not enough.
- char - for 1-byte characters
- long long - for large integers (64 bits)
input/output
c++: cin/cout
#include <iostream>
using namespace std;
main()
{
int x;
cin >> x;
cout << "answer = " << (x+1) << endl;
}
Remarks: Don't forget the using namespace line. If you do not declare that you need to prefix cin, cout, endl with std, e.g., use std::cin.