- 博客(14)
- 收藏
- 关注
原创 cmu-lab1 编译问题解决
做cmu lab1时,在终端运行gcc -O -Wall -m32 -lm -o btest bits.c btest.c decl.c tests.c报错In file included from /usr/include/stdio.h:27:0, from btest.c:16:/usr/include/features.h:367:25:
2018-01-29 20:59:45
514
转载 为什么指针为NULL还能调用成员函数?
以上程序中,下列哪个函数调用会有问题()A、b->FunctionD();B、b->FunctionB();C、b->FunctionA();D、b->FunctionC();要理解这个的话。。。成员函数其实可以认为是一个普通的函数,比如1234class A{public:void func(in
2017-09-03 22:18:06
658
原创 多个头文件相互包含编译问题
最近在写一个Tcp通信小软件,其中涉及到2个头文件,分别是“clientSocket.h”和“information.h”其中information.h文件中定义一些通信的数据结构体和一些常变量,因此在客户端套接字定义时需要包含“information.h”,即如下所示#ifndef CLIENTSOCKET_H#define CLIENTSOCKET_H#include #in
2017-07-09 17:29:21
1052
1
原创 x++与(x++)
题目int x = 4;int y = 4;x = (y++);cout输出x为多少?反汇编如下 int x = 4;013013DE mov dword ptr [x],4 int y = 4;013013E5 mov dword ptr [y],4 x = (y++);013013EC mov eax,dword pt
2017-04-08 12:02:25
502
1
原创 PAT1033.旧键盘打字
#include #include using namespace std;int ch[26] = {};int num[10] = {};int other[4] = {};int space = 0;int main(){ string bro; getline(cin,bro);//注意第2个节点测试案例第一行为空行,如果不判断的话拿不到这1分 if( bro.le
2017-03-14 22:38:41
436
原创 PAT1030完美数列
#include #include #include using namespace std;int main(){ int N; long long p; cin >> N >> p; long long s[100000] = {}; int count = 1; for ( int i = 0; i < N; ++i ) { cin >> s[i]; } s
2017-03-14 20:57:32
281
原创 PAT1028人口普查
#include #include using namespace std;class Person{public: string name; string b; Person(){} Person(string n,string bb):name(n),b(bb){} bool operator<( const Person p ) { if ( t
2017-03-13 20:41:27
597
原创 PAT1024.科学计数法
写这个题的时候头昏脑胀,思路很不清晰,写的代码很复杂,效果还不好,参考了下面的程序。整个思路比较不错,分享一下。链接如下:http://www.ithao123.cn/content-10177836.html#include #include #include using namespace std;int main(){ string s; cin>>s; int i
2017-02-16 19:59:39
336
原创 PAT1023.组个最小数
#include using namespace std;int main(){ int n[10]; for(int i=0;i<10;++i) cin>>n[i]; for(int i=1;i<10;++i) { if(n[i] != 0) { cout<<i; --n[i]; break; } } for(int i=0;i<10;++i
2017-02-16 13:08:33
359
原创 PAT1021.个位数统计
#include using namespace std;int main(){ char num[1000]; cin >> num; int i = 0; int count[10] = {}; while (num[i] != '\0') { int c = num[i++] -'0'; ++count[c]; } for(int i=0;i<10;++i)
2017-02-16 11:22:27
291
原创 PAT1020.月饼
第2个测试点一直错误,原来是stock定义为int,测试点里面应该库存也有小数,所以导致错误。更正后的代码如下:#include #include using namespace std;class mooncake{public: double stock; double price; double sp; mooncake():stock(0),price(0),sp(0)
2017-02-15 21:41:30
217
原创 PAT1018剪刀锤子布
#include using namespace std;class B{public: int num; B():num(0){} void display() { cout<<"B"; }};class C{public: int num; C():num(0){} void display() { cout<<"C"; }};class
2017-02-14 15:20:57
252
原创 PAT1003我要通过!
#include #include using namespace std;string test(char* x){int a = 0;while (*x != 'P'){if(*x != 'A'){return "NO\n";}elsea++;x++;}x++;int b = 0;while (*x != 'T')
2017-02-11 14:24:40
223
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人