2代码规范

This commit is contained in:
iridiumR 2021-10-03 11:21:32 +08:00
parent d4ad5301b5
commit b1e453a396

15
ex2.cpp
View file

@ -3,11 +3,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
class Vec class Vec
{ {
private: private:
int *v; int *v;
int LEN; int LEN;
int USED; int USED;
@ -17,7 +15,6 @@ class Vec
void shrink(); void shrink();
public: public:
Vec(int len); Vec(int len);
int get(int a); int get(int a);
@ -39,7 +36,6 @@ class Vec
int getused(); int getused();
}; };
Vec::Vec(int len) Vec::Vec(int len)
{ {
LEN = len * 2; LEN = len * 2;
@ -159,10 +155,6 @@ void Vec::printall()
printf("%d\n", v[i]); printf("%d\n", v[i]);
} }
int main() int main()
{ {
srand(time(NULL)); srand(time(NULL));
@ -171,14 +163,12 @@ int main()
int temp[10] = {0}; int temp[10] = {0};
int flag; int flag;
printf("初始化,输出数组\n"); printf("初始化,输出数组\n");
v.printall(); v.printall();
while (1) while (1)
{ {
printf("选择操作:\n1.插入\n2.删除\n3.查找\n"); printf("Ñ¡Ôñ²Ù×÷:1.²åÈë 2.ɾ³ý 3.²éÕÒ\n");
scanf("%d", &flag); scanf("%d", &flag);
switch (flag) switch (flag)
@ -209,9 +199,6 @@ int main()
printf("返回菜单\n"); printf("返回菜单\n");
} }
flag = 0; flag = 0;
} }
return 0; return 0;