跟着英雄哥学c语言 第三日
目录
一.题目
(1)思路
(2)代码
二.题目
(1)思路
(2)代码
三.题目
(1)思路
(2)代码
四.题目
(1)思路
(2)代码
链接
一.题目
709. 转换成小写字母
(1)思路
1.
s[i]=s[i]-'A'+'a';
(2)代码
char * toLowerCase(char * s){ for(int i = 0;i ='A' && s[i] <= 'Z'){ s[i]=s[i]-'A'+'a'; } } return s;}
二.题目
1812. 判断国际象棋棋盘中一个格子的颜色
(1)思路
1.利用奇偶性来判断
(2)代码
bool squareIsWhite(char * coordinates){ int a=coordinates[0]; int b=coordinates[1]; if((a%2==0&&b%2==0)||(a%2!=0&&b%2!=0)){ return false; }else{ return true; }}
三.题目
LCP 17. 速算机器人 -
(1)思路
1.符合条件即运行其运算
(2)代码
int calculate(char* s){ int x=1,y=0; int i=0; while(s[i]!='\0'){ if(s[i]='A'){ x = 2*x+y; }else{ y=2*y+x; } x+=y; i++; } return x;}
四.题目
2011. 执行操作后的变量值 - 力扣(LeetCode) (leetcode-cn.com)
(1)思路
1.符合条件即运行其运算
(2)代码
int finalValueAfterOperations(char ** operations, int operationsSize){ int i; int x=0; for(i=0;i<operationsSize;i++){ if(operations[i][1]=='+'){ x++; }else{ x--; } } return x;}
链接
(71条消息) 《C语言入门100例》_英雄哪里出来的博客-CSDN博客
(71条消息) 《算法零基础100讲》_英雄哪里出来的博客-CSDN博客
709. 转换成小写字母 - 力扣(LeetCode) (leetcode-cn.com)
1812. 判断国际象棋棋盘中一个格子的颜色 - 力扣(LeetCode) (leetcode-cn.com)
LCP 17. 速算机器人 - 力扣(LeetCode) (leetcode-cn.com)
2011. 执行操作后的变量值 - 力扣(LeetCode) (leetcode-cn.com)