【例题1】2325. 解密消息 – 力扣(LeetCode)
int isTrue(char c,char chs[26],int pos){
int i;
for(i=0;i= 'a' && isTrue(ch,chs,pos)){
*(chs+pos) = ch;
pos++;
}
cur++;
}
char* newStr = (char*)malloc(sizeof(char)*2001);
cur = 0;
while(*(message+cur) != ''){
if (*(message+cur) != ' ') {
*(newStr+cur) = lookForChar(*(message+cur),chs);
}else{
*(newStr+cur) = ' ';
}
cur++;
}
*(newStr+cur) = '';
return newStr;
}
【例题2】1379. 找出克隆二叉树中的相同节点 – 力扣(LeetCode)
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
TreeNode* getTargetCopy(TreeNode* original, TreeN服务器托管网ode* cloned, TreeNode* target) {
if(target->val == cloned->val){
return cloned;
}
if(cloned->left != NULL){
original = getTargetCopy(original,cloned->left,target);
}
if(cloned->right != NULL){
original = getTargetCopy(original,cloned->right,target);
}
return original;
}
};
【例题3】2469. 温度转换 – 力扣(LeetCode)
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
double* convertTemperature(double celsius, int* returnSize){
double* ans = (double*)malloc(sizeof(double)*2);
*(ans+0) = celsius + 273.15;
*(ans+1) = celsius*1.80 + 32.00;
*returnSize = 2;
return ans;
}
【例题4】LCR 189. 设计机械累加器 – 力扣(LeetCode)
int mechanicalAccumulator(int target) {
return target == 1 ? 1 : mechanicalAccumulator(target-1)+target;
}
【例题5】371. 两整数之和 – 力扣(LeetCode)
int getSum(int a, int b){
while(b!=0){
unsigned int temp = (unsigned int) (a&b)
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租服务器托管网用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: Terraform 实现循环for和条件判断if (10)
实现循环 (for) Terraform 中本身并不支持循环的语句,但是可以通过其他形式来实现循环的效果。 每一个资源块除了他所支持的特定参数外,Terraform 也具有一种被称为 mt acmt 元参数的参数。所谓元参数就是这种参数能够引用到任意的资源块中…