题目链接:https://leetcode-cn.com/problems/ba-zi-fu-chuan-zhuan-huan-cheng-zheng-shu-lcof/ 应该先去除字符串首部的空格,然后再判断正负。 难点在于处理溢出。 INT_MAX 2147483647 INT_MIN -214 ...
分类:
其他好文 时间:
2020-05-31 11:01:35
阅读次数:
51
顺序栈 顺序栈定义 用顺序存储结构实现的栈,即利用一组地址连续的存储单元依次存放自栈底到栈顶的数据元素,同时 由于栈的操作的特殊性,还必须附设一个栈顶指针(top)来动态的指示栈顶元素在顺序栈中的位置。 通常以 top= -1 表示栈空。 结构体定义 struct SeqStack{ int MAX ...
分类:
其他好文 时间:
2020-05-28 21:55:28
阅读次数:
76
方法参数个数 int getNum(int i){}int getNum(int i,int b,int c){} 方法参数个数不确定,参数使用数组和集合类,也可以使用... public static int max(int... n) { int m = 0; if (n.length > 0) ...
分类:
编程语言 时间:
2020-05-28 19:55:55
阅读次数:
79
#include <stdio.h>int main(){ int max,i,j,row,colum; int a[3][4]={{1,2,3,4},{9,8,7,6},{-10,10,-5,2}}; max=a[0][0]; for(i=0;i<=2;i++) { for(j=0;j<=3;j+ ...
分类:
其他好文 时间:
2020-05-23 18:13:34
阅读次数:
370
分析: 使用字符串拼接 #include <iostream>#include <cstring> using namespace std;int main(){ int score; string tem1,tem2, stuma , stumi; int max=-1 , min=10000;i ...
分类:
其他好文 时间:
2020-05-22 19:04:14
阅读次数:
45
C++中, 经常会使用, 某些类型的最大值, 如int的最大整数(INT_MAX), C的函数中, 包含了这些宏定义. 头文件: 具体参见: |name | expresses |value | |: |: |: :| |CHAR_BIT | Number of bits in a?char?obj ...
分类:
编程语言 时间:
2020-05-12 09:30:12
阅读次数:
81
题目: 解答: 1 class MaxQueue { 2 queue<int> q; 3 deque<int> d; 4 public: 5 MaxQueue() { 6 } 7 8 int max_value() 9 { 10 if (d.empty()) 11 return -1; 12 ret ...
分类:
其他好文 时间:
2020-05-09 21:39:21
阅读次数:
57
题目: 解答: 1 class Solution { 2 public: 3 int maxProfit(vector<int>& prices) 4 { 5 int cost = INT_MAX; 6 int profit = 0; 7 for (int price: prices) 8 { 9 ...
分类:
其他好文 时间:
2020-05-09 20:50:03
阅读次数:
59
#include<stdio.h>#include<stdlib.h>typedef struct{ int max,min;}Data;int MIN;//通过函数返回最大值,通过全局变量MIN带回最小值int fun1(int a[],int n){ int i,max; max=MIN=a[0 ...
分类:
其他好文 时间:
2020-05-05 15:13:13
阅读次数:
80
函数指针: 函数指针是指向函数的指针变量,并且函数指针可以像一般函数一样,用于调用函数、传递参数. 指针变量的声明:typedef (* 定义的名字) (参数,参数) ,such as: int (*fun_ptr)(int,int); 源码: #include<stdio.h> int max(i ...
分类:
其他好文 时间:
2020-05-04 17:50:27
阅读次数:
71