第一次刷Leetcode!这个系列会已知更新下去的!
由于作者太废,所以只能先更:【新】动计划---编程入门
题目简单 ,不愧是第一题!这题考察的是函数的返回值。
ACcode :
class Solution {
public:
int sum(int num1, int num2) {
return (num1+num2);
}
};
这题简单只需明白各个温度之间的进率就可以了,最后返回函数值
ACcode
class Solution {
public:
vector<double> convertTemperature(double celsius) {
return {celsius+273.15,celsius*1.80+32.00};
}
};
拆数过程:
while(n!=0){
t=n%10;
//执行操作,如,依次相乘之类的
n=n/10;
}
ACcode
class Solution {
public:
int subtractProductAndSum(int n) {
int t,cnt=1,ant=0;
while(n!=0){
t=n%10;
ant+=t;
cnt*=t;
n=n/10;
}
return (cnt-ant);
}
};
这一期就草草结束了,哈哈哈哈哈哈哈。。。。