This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.
| « | 七月 2009 | » | ||||
|---|---|---|---|---|---|---|
| 一 | 二 | 三 | 四 | 五 | 六 | 日 |
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | ||
出口香烟
FC 4下安装ORACLE 9i 的全过程
安装Linux 的硬盘分区
C语言面试题大汇总之华为面试题
面试经典试题
C/C++ 程序设计员应聘常见面试试题深入剖析
美国军工五巨头简介
经典面试问题回答思路
老师的语录
华为公司 java 面试题
1.设计函数 int atoi(char *s)
2. What do the following declarations mean?
(1)const int a;
(2)int const a;
(3)const int *a;
(4)int * const a;
(5)int const * a const;
3.编程
将整数转换成字符串:void itoa(int,char);
例如itoa(-123,s[])则s=“-123”;
4.10个人分成4组 有几种分法?(程序)(不能重复,如:1,1,1,7=7,1,1,1)
5.如图:
7 8 9 10
6 1 2 11
5 4 3 12
16 15 14 13
设“1”的坐标为(0,0) “7”的坐标为(-1,-1) 编写一个小程序,使程序做到输入坐标(X,Y)之后显示出相应的数字。
6.编最优化Bubble(int *pIntArray,int L),要求:交换元素不能用临时变量,如果有序需要最优。
6.
void bubble(int* pSrc,int length)
{
int i,j;
for(i=n;i>2;i--)
{
for(j=1;j<i-1;j++)
{
if(pSrc[j]>pSrc[j+1])
{
pSrc[j]=pSrc[j]^pSrc[j+1];
pSrc[j+1]=pSrc[j+1]^pSrc[j];
pSrc[j]=pSrc[j]^pSrc[j+1];
}
}
}
}
1.
int atoi(char *s)
{
int result = 0;
int i, j, m, temp;
char c;
j = 0;
while(s[j]!='')
{
j++;
}
for(i=j-1;i>=0;i--)
{
c = s[i];
temp = c - '0';
for(m=0;m<j-i-1;m++)
{
temp = temp*10;
}
result = result + temp;
printf("c=%d, temp=%d, result=%dn", c, temp, result);
}
return result;
}
2,(1)const int a;表示常量
(2)int const a;表示常量
(3)const int *a;指针a指向的数据不允许改变
(4)int * const a;指针a的地址不变
(5)int const * a const;地址,数据都不允许改变
6.最优
void bubble(int *a,int n)
{
int i,j,change;
for(i=1,change=1; i<n && change; ++i)
{
change = 0;
for (j=0; j<n-i; ++j)
if (a[j] > a[j+1])
{
a[j]=a[j]^a[j+1];
a[j+1]=a[j+1]^a[j];
a[j]=a[j]^a[j+1];
}
}
}
void bubble(int *a,int n)
{
int i,j,change;
for(i=1,change=1; i<n && change; ++i)
{
change = 0;
for (j=0; j<n-i; ++j)
if (a[j] > a[j+1])
{
a[j]=a[j]^a[j+1];
a[j+1]=a[j+1]^a[j];
a[j]=a[j]^a[j+1];
change=true;
}
}
}
5.如图:
7 8 9 10
6 1 2 11
5 4 3 12
16 15 14 13
设“1”的坐标为(0,0) “7”的坐标为(-1,-1) 编写一个小程序,使程序做到输入坐标(X,Y)之后显示出相应的数字。
#include <iostream.h>
int x1=0,y1=0,x2=0,y2=0;
int main(){
int i,j,n,num=1;
cout<<"Please input x-coordinate: ";
cin>>x1;
cout<<"Please input y-coordinate: ";
cin>>y1;
for(i = 2;i < 6;i++)
for(n = 0;n < 2;n++)
for(j = 1;j < i;j++){
if(i % 2){
if(n == 0){
if((x1 == x2)&&(y1 == y2))
break;
y2--;
num++;
}
else{
if((x1 == x2)&&(y1 == y2))
break;
x2--;
num++;
}
}
else{
if(n == 0){
if((x1 == x2)&&(y1 == y2))
break;
y2++;
num++;
}
else{
if((x1 == x2)&&(y1 == y2))
break;
x2++;
num++;
}
}
}
cout<<"x-coordinate: "<<x1<<" y-coordinate: "<<y1<<endl;
cout<<"The number is: "<<num<<endl;
return 0;
}
第五题:先找到所有平方数的位置,是有规律的:
奇数平方数1,9,25……在从1开始想右上直线延伸,4,16,36……从4开始向左下直线延伸,这样可以快速确定平方数位置。输入n,求得n两边的平方数,例如输入27,则确定25和36位置,中间从26到36的5+6=11个数位置就是联系排列,只有一个拐弯,在26+5=31处,接下来不就ok了?