int isLegal(char* ipaddr)
{
int flag;
int curVal; //curVal 表示分析出的一个十进制数
int decNum=0,dotNum=0; // decNum 用于记录十进制数的个数
//dotNum 用户记录点的个数
char* p=( )
for (;*p;p++) {
curVal=0;flag=0;
while (isdigit(*p)) { //判断是否伟数字字符
curVal=( )+*p-′0′;
( )
flag=1;
}
if (curVal>255) {
return 0;
}
if (flag) {
( )
}
if (*p=′.′) {
dotNum++;
}
}
if ( ) {
return 1;
}
return 0;
}
int indexStr(SString S, SString T, int pos)
{
int i,j:
if (S.length<1||S.length<pos+T.length-1)
return-1;
for (i=pos,j=0;i<S.length &&j<T.length;) {
if (S.str[i]==T.str[j]) {
i++;j++;
} else {
i=( );j=0;
}
}
if ( ) return i -T.length;
return-1;
}
void eraseStr(SString*S,SStringT)
{
int i;
int pos;
if (S->length<||T.length<1||S->length<T.length)
return;
pos=0;
for (;;) {
// 调用 indexStr 在 S 所表示串的 pos 开始查找 T 的位置
pos=indexStr( );
if (pos=-1) // S 所表示串中不存在子串 T
return;
for (i=pos+T.length;i<S->length;i++) // 通过覆盖来删除自串 T
S->str[( )]=S->str[i];
S->length=( ); //更新 S所表示串的长度
}
}
int enqueue(queue* q, KeyType new_elem)
{ //元素 new_elem 入队列
qNode* p;
p=(qNode*)malloc(sizeof(qNode));
if (!p)
return errOr;
p->data=new_elem;
if (q->rear) {
p->next=q->rear->next;
( );
}
else
p->next=p;
( );
q->size++;
return OK;
}
int dequeue(queue* q, KeyType* elem)
{ //出队列
qNode* p;
if (0==q->size) //是空队列
return errOr;
p=( ); //令 p 指向队头元素结点
*elem =p->data;
q->rear->next=( ); //将队列元素结点从链表中去除
if (( )) //被删除的队头结点是队列中唯一结点
q->rear=NULL //变成空队列
free(p);
q->size--;
return OK;
}
abstract class Customer {
protected String name;
( ) boolean isNil();
( ) String getName();
}
class realCustomer ( ) Customer {
public realCustomer(String name) { this.name=name; }
public String getName() { return name; }
public boolean isNil() { return false; }
}
class NullCustomer ( ) Customer {
public String getName() { return "Not Available in Customer Database"; }
public boolean isNil() { return true; }
}
class Customerfactory {
public String[] names = {"rob","Joe","Julie"};
public Customer getCustomer(String name) {
for (int i = 0; i < names.length;i++) {
if (names[i].( )){
return new realCustomer(name);
}
}
return ( );
}
}
public class CRM {
public viod getCustomer() {
Customerfactory( )
Customer customer1 = cf.getCustomer("rob");
Customer customer2 = cf.getCustomer("rob");
Customer customer3 = cf.getCustomer("Julie");
Customer customer4 = cf.getCustomer("Laura");
System.out.println(customer1.getName());
System.out.println(customer2.getName());
System.out.println(customer3.getName());
System.out.println(customer4.getName());
}
public static viod main(String[] args) {
CRM crm =new CRM();
crm.getCustomer();
}
}
#include<iostream>
#include<string>
using namespace std;
class Customer{
protected:
string name;
public:
( 1 ) boll isNil()=0;
( 2 ) string getName()=0;
};
class realCustomer ( 3 ) {
public:
realCustomer(string name){this->name=name; }
bool isNil(){ return false; }
string getName(){ return name; }
};
class NullCustomer ( 4 ) {
public:
bool isNil() { return true; }
string getName() { return "Not Available in Customer Database"; }
};
class Customerfactory {
public:
string names[3]= {"rob", "Joe", "Julie"};
public:
Customer* getCustomer(string name) {
for (int i=0;i<3;i++) {
if (names[i].( 5 ) ) {
return new realCustomer(name);
}
}
return ( 6 );
}
};
class CRM {
public:
void getCustomer() {
Customerfactory* ( 7 );
Customer*customer1=cf->getCustomer("rob");
Customer*customer2=cf->getCustomer("Bob");
Customer*customer3=cf->getCustomer("Julie");
Customer*customer4=cf->getCustomer("Laura");
cout<<"Customers"<<endl;
cout<<Customer1->getName() <<endl; delete customer1;
cout<<Customer2->getName() <<endl; delete customer2;
cout<<Customer3->getName() <<endl; delete customer3;
cout<<Customer4->getName() <<endl; delete customer4;
delete cf;
}
};
int main() {
CRM* crm=new CRM();
crm->getCustomer();
delete crm;
return 0;
}
1. 试题参考答案和解析查看;
2. 试卷模拟测试;
3. 随机组题测试;
4. 赠送等值学豆;