在线笔试题目解答
2007-07-02 16:36
309 查看
1.a.POINT *p;
b.POINT **p;
c.POINT p[16];
d.POINT **p;
e.POINT *p = new POINT[16];
2.
#include <iostream>
using namespace std;
//判断是否为偶数的函数
//是偶数,则返回1,否则返回0
int isEven(int n)
...{
/**//*if(n%2==0)
return 1;
else
return 0;
*/
//采用位运算,速度很快~!
if(n&1)
return 0;
else
return 1;
}
void main()
...{
int i,j;
cin>>i;
j = isEven(i);
if(j)
cout<<i<<" 是偶数"<<endl;
else
cout<<i<<" 是奇数"<<endl;
getchar();
}
3.
#include <iostream>
#include <string>
using namespace std;
/**//*
*思路:遍历字符串得到数字的第一个出现的位置firstNum
* 遍历字符串然后将字母出现在firstNum之后的插入到firstNum之前
* 遍历字符串得到数字的最后一个出现的位置lastNum
* 倒序遍历字符串然后将字符出现在lastNum之前的插入到lastNum之后
*/
int strlength(char *pstr)
...{
int k =0 ;
while(true)
...{
//遇到终结符则退出
if(pstr[k] == '
4.
#include <iostream>
using namespace std;
void parseBary(int n)
...{
int i=0;
int a[100];
while(true)
...{
if(n==0)
break;
a[i] = n%2;
n = n/2;
i++;
}
int temp[10];
int count[10];
for(int k=0;k<10;k++)
...{
count[k]=1;
}
//计数器
int x = 0;
for(int j=0;j<i;j++)
...{
if(a[j]==a[j+1])
...{
count[x]++;
}
else
...{
temp[x] = a[j];
x++;
}
}
for(int z=0;z<x;z++)
...{
cout<<temp[z]<<": "<<count[z]<<endl;
}
}
void main()
...{
cout<<"请输入您要验证的十进制数字:";
int a;
cin>>a;
cout<<"结果如下:"<<endl;
parseBary(a);
}
5.
#include <iostream>
using namespace std;
class Student
...{
private:
char name[20];
int year;
int month;
int day;
public:
Student();
Student(char *n,int y,int m,int d);
Student(Student &s);
~Student();
Student &operator > (Student &s);
void display()
...{
cout<<"姓名:"<<name<<endl
<<"生日:"<<day<<"/"<<month<<"/"<<year<<endl;
}
};
Student::Student()
...{
strcpy(name,"zcg");
this->year = 1984;
this->month = 8;
this->day = 21;
}
Student::Student(Student &s)
...{
strcpy(name,s.name);
year = s.year;
month = s.month;
day = s.day;
}
Student::Student(char *n,int y,int m,int d)
...{
strcpy(name,n);
this->year = y;
this->month = m;
this->day = d;
}
Student::~Student()
...{
}
Student & Student::operator >(Student &s)
...{
if(this->year>s.year)
return s;
else if(this->year<s.year)
return *this;
else if(this->month>s.month)
return s;
else if(this->month<s.month)
return *this;
else if(this->day>s.day)
return s;
else
return *this;
}
void main()
...{
Student s1("test1",1985,2,20);
Student s2("test2",1985,3,8);
Student s = s1>s2;
cout<<"年龄大的是: "<<endl;
s.display();
getchar();
}
6.
#include <....>
.....
.....
/**//*
*HANDLE FindFirst(char* lpFileName);//用于查找给定目录下是否有指定文件。若无则返回0,若有则返回一个句柄。例如:FindFirst("D:/data/*.txt")
*BOOL FindNext(HANDLE hFindFile); //继续查找该目录下是否有其他匹配文件。
*BOOL FindClose(HANDLE hFindFile);//用于结束查找。
*/
int NumOfPicFiles(char*lpszfolder);
main()
...{
int jpg = NumOfPicFiles("D:/*.JPG");
int bmp = NumOfPicFiles("D:/*.BMP");
cout<<"一共有 "<<jpg<<" 个JPG文件"<<endl;
cout<<"一共有 "<<bmp<<" 个BMP文件"<<endl;
}
int NumOfPicFiles(char*lpszfolder)
...{
int count = 0;
HANDLE handle = FindFirst(lpszfolder);
if(handle!=0)
return count;
else if(FindFirst(handle))
...{
count++;
}
FindClose(handle);
}
b.POINT **p;
c.POINT p[16];
d.POINT **p;
e.POINT *p = new POINT[16];
2.
#include <iostream>
using namespace std;
//判断是否为偶数的函数
//是偶数,则返回1,否则返回0
int isEven(int n)
...{
/**//*if(n%2==0)
return 1;
else
return 0;
*/
//采用位运算,速度很快~!
if(n&1)
return 0;
else
return 1;
}
void main()
...{
int i,j;
cin>>i;
j = isEven(i);
if(j)
cout<<i<<" 是偶数"<<endl;
else
cout<<i<<" 是奇数"<<endl;
getchar();
}
3.
#include <iostream>
#include <string>
using namespace std;
/**//*
*思路:遍历字符串得到数字的第一个出现的位置firstNum
* 遍历字符串然后将字母出现在firstNum之后的插入到firstNum之前
* 遍历字符串得到数字的最后一个出现的位置lastNum
* 倒序遍历字符串然后将字符出现在lastNum之前的插入到lastNum之后
*/
int strlength(char *pstr)
...{
int k =0 ;
while(true)
...{
//遇到终结符则退出
if(pstr[k] == '
4.
#include <iostream>
using namespace std;
void parseBary(int n)
...{
int i=0;
int a[100];
while(true)
...{
if(n==0)
break;
a[i] = n%2;
n = n/2;
i++;
}
int temp[10];
int count[10];
for(int k=0;k<10;k++)
...{
count[k]=1;
}
//计数器
int x = 0;
for(int j=0;j<i;j++)
...{
if(a[j]==a[j+1])
...{
count[x]++;
}
else
...{
temp[x] = a[j];
x++;
}
}
for(int z=0;z<x;z++)
...{
cout<<temp[z]<<": "<<count[z]<<endl;
}
}
void main()
...{
cout<<"请输入您要验证的十进制数字:";
int a;
cin>>a;
cout<<"结果如下:"<<endl;
parseBary(a);
}
5.
#include <iostream>
using namespace std;
class Student
...{
private:
char name[20];
int year;
int month;
int day;
public:
Student();
Student(char *n,int y,int m,int d);
Student(Student &s);
~Student();
Student &operator > (Student &s);
void display()
...{
cout<<"姓名:"<<name<<endl
<<"生日:"<<day<<"/"<<month<<"/"<<year<<endl;
}
};
Student::Student()
...{
strcpy(name,"zcg");
this->year = 1984;
this->month = 8;
this->day = 21;
}
Student::Student(Student &s)
...{
strcpy(name,s.name);
year = s.year;
month = s.month;
day = s.day;
}
Student::Student(char *n,int y,int m,int d)
...{
strcpy(name,n);
this->year = y;
this->month = m;
this->day = d;
}
Student::~Student()
...{
}
Student & Student::operator >(Student &s)
...{
if(this->year>s.year)
return s;
else if(this->year<s.year)
return *this;
else if(this->month>s.month)
return s;
else if(this->month<s.month)
return *this;
else if(this->day>s.day)
return s;
else
return *this;
}
void main()
...{
Student s1("test1",1985,2,20);
Student s2("test2",1985,3,8);
Student s = s1>s2;
cout<<"年龄大的是: "<<endl;
s.display();
getchar();
}
6.
#include <....>
.....
.....
/**//*
*HANDLE FindFirst(char* lpFileName);//用于查找给定目录下是否有指定文件。若无则返回0,若有则返回一个句柄。例如:FindFirst("D:/data/*.txt")
*BOOL FindNext(HANDLE hFindFile); //继续查找该目录下是否有其他匹配文件。
*BOOL FindClose(HANDLE hFindFile);//用于结束查找。
*/
int NumOfPicFiles(char*lpszfolder);
main()
...{
int jpg = NumOfPicFiles("D:/*.JPG");
int bmp = NumOfPicFiles("D:/*.BMP");
cout<<"一共有 "<<jpg<<" 个JPG文件"<<endl;
cout<<"一共有 "<<bmp<<" 个BMP文件"<<endl;
}
int NumOfPicFiles(char*lpszfolder)
...{
int count = 0;
HANDLE handle = FindFirst(lpszfolder);
if(handle!=0)
return count;
else if(FindFirst(handle))
...{
count++;
}
FindClose(handle);
}
相关文章推荐
- 在线笔试题目
- 谷歌校园招聘在线笔试题题目一道
- 微软2014实习生及秋令营技术类职位在线测试 原创解答 题目1 : String reorder
- 2016 微软秋招(校招)在线笔试 题目1 : Farthest Point
- 笔试题目解答
- 网易互娱2017在线笔试——题目一:电子数字
- 2014亚马逊在线笔试题目及解决方案(MMChess问题)
- 2014年亚马逊在线笔试题目及解法_9_24(字符串编辑距离升级版)
- 网易互娱2017实习生招聘在线笔试第一场 题目1 : 电子数字
- 2016 微软秋招(校招)在线笔试 题目234
- 2014亚马逊在线笔试题目
- 魔力手环-网易互联网2017在线笔试题目
- 网易互娱2017实习生招聘在线笔试第一场题目解析
- 网易互娱2017实习生招聘在线笔试第一场-题目3
- 题目3 : Spring Outing 微软2016校园招聘在线笔试第二场
- 一个关于SQL的笔试题目及解答
- 腾讯在线模拟笔试题目,格雷码问题
- 2018大疆校招软件岗位笔试题目(求有效工作时间)——未在线验证
- 阿里巴巴2013.5.5 实习生招聘笔试题目及解答
- 网络上看到的Google笔试题目-我的解答