赞
踩
- #include <math.h>
- #define FALSE -1
- #define TRUE 0
-
- int parseSoundSetting(char* configure, stSoundSetting* setting)
- {
- if( *configure == 'I' && *(configure+1) == 'D' && *(configure+2) == '_' && *(configure+3) == 'S'
- && *(configure+4) == 'O' && *(configure+5) == 'U' && *(configure+6) == 'N'
- && *(configure+7) == 'D' && *(configure+8) == '_' ) //前缀合法
- {
- int i=9;
- int j=0;
- while( *(configure+i) != '_' ) //检查功放型号
- {
- setting->amplifier[j] = *(configure+i);
- i++;
- j++;
- }
- setting->amplifier[j] = '\0'; //末尾补上结束符
- j=0; //清零,记录下一个偏移值
-
-
- while( *(configure+i) != '_' ) //检查机型号
- {
- setting->modelname[j] = *(configure+i);
- i++;
- j++;
- }
- setting->modelname[j] = '\0'; //末尾补上结束符
- j=0; //清零,记录下一个偏移值
-
-
- char vol[3];
- char imped[8];
- char powe[5];
- while( *(configure+i) != 'V' && *(configure+i) >='0' && *(configure+i) <='9' ) //电压
- {
- vol[j] = *(configure+i);
- i++;
- j++;
- }
- vol[j] = '\0'; //末尾补上结束符
- int count=0; //计算字符长度,即将要转化为整数的位数
- while(vol[j] != '\0')
- count++;
- for(int k=0; k<count;k++)
- {
- setting->voltage = (vol[k]-'0') * pow(10,count-k);
- }
- j=0; //清零,记录下一个偏移值
- count=0;
-
-
- while( *(configure+i) != 'R' && *(configure+i) >='0' && *(configure+i) <='9' ) //电阻
- {
- imped[j] = *(configure+i);
- i++;
- j++;
- }
- imped[j] = '\0'; //末尾补上结束符
- while(imped[j] != '\0')
- count++;
- for(int k=0; k<count;k++)
- {
- setting->impedance = (imped[k]-'0') * pow(10,count-k);
- }
- j=0; //清零,记录下一个偏移值
- count=0;
-
-
- while( *(configure+i) != 'W' && *(configure+i) >='0' && *(configure+i) <='9' ) //功率
- {
- powe[j] = *(configure+i);
- i++;
- j++;
- }
- power[j] = '\0'; //末尾补上结束符
- while(power[j] != '\0')
- count++;
- for(int k=0; k<count;k++)
- {
- setting->power = (powe[k]-'0') * pow(10,count-k);
- }
-
- return TRUE; //解析成功
-
- }
-
- else
- return FALSE; //解析失败
- }
总结:基本围绕项目展开,然后根据你回答里提到的相关术语,再做进一步提问,所以主动权其实在你,你向什么地方引,面试官可能就会顺着这个话题提问。(⊙o⊙)…虽然问的都比较基础,但是自己第一次面试,比较紧张慌乱之下,可能回答的不是很完善。。。
- //CVTE一面:线上面试 判断一个数是否为2的幂 循环+递归
- #include <iostream>
- using namespace std;
-
- void isMI(double num)
- {
- if (num > 1)
- isMI(num / 2);
- ///if (num < 1)
- //isMI(num * 2);
- else if (num == 1)
- cout << "YES" << endl;
- else
- cout << "NO" << endl;
- }
- int main()
- {
- //double num;
- //cin >> num;
- //while (num > 1)
- // num /= 2;
- //while (num > 0 && num < 1)
- // num *= 2;
- //if (num == 1)
- // cout << "YES" << endl;
- //else
- // cout << "NO" << endl;
- double num;
- cin >> num;
- isMI(num);
- /*if (isMI(num) == true)
- cout << "YES" << endl;
- else
- cout << "NO" << endl;*/
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。