0721 c++笔记
1.长整型
#include <iostream>
using namespace std;
int main() {
int a = 125;//定义整型变量a
long long b = 241748364856789;//定义长整型变量b
cout << a << endl << b;//输出变量的值
}
格式:long long 变量名1,变量名2,……
long long a,b,……
2.char(ascii码表)
#include <iostream>
using namespace std;
int main(){
//输入数字65,得到字符"A"
char a ;
a = 97;
cout<<a;
return 0;
}
#include <iostream>
using namespace std;
int main(){
int a=25,b=31;
float h;//定义浮点型变量h
h=a*b/2.0;
cout<<h;
return 0;
}
顺序结构
#include <iostream>
using namespace std;
int main() {
int s = 52, c = 686;
float p;
p = s * 1.0 / c * 100;
cout << p<<"%";
return 0;
}