C++ 数组的各类性质和用法

chanra1n 2020-11-03 803
#include<iostream>  using namespace std; void addarr(int *k,int len); //文中形如sizeof(x)/sizeof(x[0]) 是用数组占用空间大小除以成员的大小,即得数组长度  //三种不同的数组声明方式  int x[5]={1,2,3,4,5}; int y[]={2,4,6,8,10};

数据结构

chanra1n 2020-10-28 925
#include<iostream> using namespace std; struct books{ char name[10]; int num; float price; }book; int main() { book.num=1; book.price=2.5; char x[10]="Hello",n; for(n=0;n<1

C和C++中的字符串

chanra1n 2020-10-28 833
/*C风格字符串的声明和使用  #include<cstdio.h> int main() { char x[]={'H','e','l','l','o',' ','C','+','+','\0'}; //等效于 char x[]="Hello

Break和Continue的区别

chanra1n 2020-10-28 924
#include<iostream>  using namespace std; int main() { int x=0; for(x=0;x<10;x++) { if(x==3) break; else cout << x; } cout << endl; for(x=0;x<10;x++) {

变量作用域

chanra1n 2020-10-28 849
#include<iostream> void print(); int main() { char a=0; for(a=0;a<20;a++) print(); return 0;  }  void print() { static int x=0;//静态变量声明,其值会一直保留  x++; std::cout<<x<

函数声明和使用

chanra1n 2020-10-28 870
#include<iostream> using namespace std; int sum(int a,int b);//函数声明  int main() { cout << sum(1,2);//函数调用  return 0; } int sum(int a,int b)//函数主体  { r

数据类型及其占用空间

chanra1n 2020-10-28 796
#include<iostream> using namespace std; int main() { cout << "The size of int is " <<sizeof(int) <<endl; cout << "The size&

C++入门 输出Hello World

chanra1n 2020-10-28 842
#include <iostream>using namespace std;int main(){     cout << "Hello, world!" << endl;    return 0;}它等效于#include <iostream

C++的继承和派生

chanra1n 2019-11-06 1692
#include <iostream> using namespace std; class fenshu { public: int xuehao; int yuwen;  };   class wz_fenshu:public fenshu  {   public:   int shuxue; &

C++的类和对象

chanra1n 2019-11-06 1672
什么是类和对象?张三找了一个女朋友,她的女朋友就是他的对象。搞笑一下,打个比方,我们都是人类,人类这个类的一个成员(对象)。怎么创建类呢?#include <iostream> using namespace std; class fenshu { public: int xuehao; int yuwen; int shuxue; }; int main ()