- 博客(9)
- 收藏
- 关注
原创 算法第三题
解题思路 1、先删去字符串中的符号与空格 2、将英文全部转换成小写 3、比较首位是否一一对应 class Solution { public: bool isPalindrome(string s) { if(s.size()<1) return true; string news; for(int i=0;i<s.size();i++) { if((47<s[i]&&s[i]&
2021-10-26 19:43:00
128
1
原创 算法第二题
解题思路 首先从后往前排除空格,遇到第一个字母(从后往前)便开始计算。 第一次提交的问题是遇到“day”,也就是单词前无空格,所以i又会遍历,导致错误计数。 所以在for循环后加入判断count是否>0,是的话就直接return。 class Solution { public: int lengthOfLastWord(string s) { int len = s.size(); int count=0; int i,j; f
2021-10-26 19:40:02
113
原创 算法第一题
解题思路 遍历要判断的字符串,找到第一个有可能的字母,然后从此的下一位开始对比,如果各位均对应相等则直接return出 这个字母的位置,注意空串的输出为0,其余情况均为-1; typedef unsigned long long ULL; class Solution { public: int strStr(string haystack, string needle) { if(needle.size() == 0) return 0; int p = 131;
2021-10-26 19:36:49
108
原创 函数练习1
#include<stdio.h> #include<string.h> #define NAME "WangHao" #define AGE 19 #define ADDRESS "Tian_jin Wq" #define WIDTH 40 #define SPACE ' ' void show_n_char(char ch, int num); int main() { show_n_char('*', WIDTH); printf("\n"); show_
2021-06-04 15:02:39
110
原创 martix准备 Day2
martix准备 Day2 name=input("你的名字:") age=int(input("你的年龄:")) weight=input("你的体重:") height=input("你的身高:") msg=''' ————————————inform———————————————— 你的名字:%s 你的年龄:%d 你的体重:%s 你的身高:%s ————————————end———————————————————— '''%(name,age,weight,height) print(msg)
2021-04-21 22:28:02
99
原创 if的镶嵌
肝了一个小时,调了无数次,一直分不清楚if的镶嵌,终于懂了! #include<stdio.h> int main() { int age; printf("输入年龄:"); scanf_s("%d", &age); if (age <= 18) { printf("未成年"); return 0; } if (age > 18) { if (age > 70) { printf("老年"); return 0;
2021-04-19 21:06:53
619
原创 if.....else用法
#include<stdio.h> int main() { int age,englishi_score; printf("please input your age:\n"); scanf_s("%d",&age); printf("please input your englishi_score:\n"); scanf_s("%d", &englishi_score); if (age >= 18||englishi_score>=100) {
2021-04-17 11:13:39
224
原创 税率运算
#include <stdio.h> int main()`` { float money, huilv; printf(“人民币:”); scanf_s("%f", &money); huilv = money * 0.05 + money; printf(“huilv=%f”, huilv); return 0; }
2021-03-21 22:05:12
159
原创 球体体积
#include<stdio.h> #define PI 3.14 int main() { float R, V; printf(“请输入球体半径:”); scanf_s("%f", &R); V = R * R * R * PI * 3.0f / 4.0f; printf(“球体的体积为:%f”, V); return 0; }`@球体体积运算 欢迎使用Markdown编辑器 你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Markdown编辑器
2021-03-21 22:02:07
255
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅