類型 | 空間 | range |
---|---|---|
bool | 1 bit | (0 to 1 )or (true to false) |
int | 2 Bytes(2*8 bit) | -2^15 to 2^15-1 |
long int | 4 Bytes(4*8 bit) | -2^23 to 2^23-1 |
long long int | 8 Bytes(4*8 bit) | -2^31 to 2^31-1 |
float | 4 Bytes(4*8 bit) | |
doblue | 8 Bytes(8*8 bit) |
#include <stdio.h>
int main()
{
int var_name;
int w2,ww;
var_name=4;
w2=1;
ww=42342;
}
float test=10;
float var= 0.003;
double test=10;
double var= 0.003;
//宣告
int mo={0,1,2,3};
int num[4],mo[4];
float num[4],mo[4];
double num[4],mo[4];
char num[4],mo[4];
//儲存資料
mo[0]=0;
mo[1]=1;
mo[2]=2;
mo[3]=3;
//讀取資料
printf("%.3f", mo[3]);
//int
printf("%d",a);
//float or double
printf("%lf",a);
//string
printf("%s",a);
//輸出
//特殊字元
//換行
printf("\n");
//tab
printf("\t");
//\
printf("\\");
int a;
scanf("%d",&a);
float b;
scanf("%lf",&b);
char c[] = "some text";
scanf("%s",&c);
//判別式
a<b
a>b
a==b
int a ,b;
a=2;
b=3;
if(a>b)
{
printf("%d big", a);
}
else
{
printf("%d big", b);
}
#include <stdio.h>
int main()
{
int i;
for (i = 0; i < 100; i++)
{
printf("%d\n", i);
}
}
#include <stdio.h>
int main()
{
int i=0;
while(i<10)
{
printf("%d\n", i);
i=i+1;
}
return 0;
}
int test_function(int a,int b)
{
int var;
var=a*b;
return var;
}
int something = test_function(4,8)
void test(int a)
{
printf("%d",a);
}
int main()
{
int var;
var = 12;
test(var);
return 0;
}
void test(int a)
{
printf("a1 %d\n", a);
a = 10;
printf("a2 %d\n", a);
//10
}
int main()
{
int var = 8;
printf("va1 %d\n", var);
test(var);
printf("va2 %d\n", var);
return 0;
}
//8
void test(int &a)
{
printf("a1 %d\n", a);
a = 10;
printf("a2 %d\n", a);
//10
}
int main()
{
int var = 8;
printf("va1 %d\n", var);
test(var);
printf("va2 %d\n", var);
return 0;
}
//10
void test(int* a)
{
printf("a1 %d\n", a);
printf("a1_v %d\n", *a);
*a = 10;
printf("a2 %d\n", a);
printf("a2_v %d\n", *a);
}
int main()
{
int var = 8;
printf("va1 %d\n", var);
test(&var);
printf("va2 %d\n", var);
return 0;
}
//10
public 可以讀取
private 不可讀取
class test {
public:
int a=10;
int b;
int DoSomething();
void printf(int a)
{
printf("%d",test::a);
}
private:
int size;
string color;
};
int test::DoSomething() {
return a + b;
}
int main(){
test d;
printf("%d",d.a);
}
class test {
public:
int m_a=10;
int m_b;
int DoSomething();
//constructer
test(){
m_a=0;
m_b=1;
}
//constructer
//initialize list: constructerwill initialize child var before constructer
test(int a,int b):m_a(a),m_b(b){}
//destructor
~test(){
//destructor will call when the var is going to be remove
delete m_a;
delete m_b;
}
}
int main(){
test d1();
test d2;
printf("%d",d1.a);
}
class test {
public:
int m_a=10;
int m_b;
//call when the another need copy of the value
test(const test &set_test){
this->m_a=set_test.m_a;
this->m_b=set_test.m_b;
}
}
int main(){
test d1(1,2);
test d2=d2;
printf("%d",d2.a);
}
class test {
public:
int m_a=10;
int m_b;
//call when var need to be overwrite by another var
//so need to free the child var
//"conset" mean this funciton will not change the input argement var
//"&test mean" return the reference of the var
//"&set_test" mean input the reference of the var
&test operator =(const test &set_test){
delete this->m_a;
delete this->m_b;
this->m_a=set_test.m_a;
this->m_b=set_test.m_b;
return *this
}
}
int main(){
test d1(1,2);
test d2(3,4);
d1=d2;
printf("%d",d1.a);
}
int tem=0;
void main(){
::tem=::tem+10;
}
class test {
public:
int a=10;
int b;
int something();
};
int test::something(){
printf(this->a);
}
System::Math::Sqrt()=System.Math.Sqrt()
class test {
public:
int a=10;
int b;
int something();
};
int test::something(){
printf(this->a);
}
struct a{
int v=10;
int b;
};
int something(a *a_ptr){
printf(a_ptr->v);
printf(*(a_ptr).v);
}
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing