最后一个空格问题:
删除元素可使用标记法。(链表删除元素。)
数组过大超过限制,可定义为全局变量。开一个20000大小的数组,用memset函数赋初值。
给出范围的一定要对范围左右端点进行大小排序,不然可能会吃亏(训练赛A题)
数据处理的问题,要注意边界值,比如0 -1 最大值N等的特殊性,写代码要严谨,确保输入数据在所给范围之内。(判断素数,“1”)
保留小数的问题
#include<iostream>
#include<iomanip>
using namespace std;
cout<<setiosflags(ios::fixed)<<setprecision(2)<<小数;
#include<string>
string a;
getline(cin,a);
while((scanf("%s",s[count++]))!=EOF) 或者
while(scanf("%s",s[count])!=EOF&&source[n][count]) 或者
while(gets(s[count])&&s[count][0])
char *s="GoldenGlobalView";
char *l="lob";
char *p; p=strstr(s,l);
if(p) printf("%s",p);
else printf("NotFound!");
unsigned int : 0~4294967295
int : 2147483648~2147483647
unsigned long : 0~4294967295
long : 2147483648~2147483647
long long的最大值 :9223372036854775807
long long的最小值 :-9223372036854775808
unsigned long long的最大值:18446744073709551615
__int64的最大值 :9223372036854775807
__int64的最小值 :-9223372036854775808
unsigned __int64的最大值:18446744073709551615
等差数列*2-1 ,即每一组的字符总数为 2Sn-1
加—— a+b: a=a.add(b);
减—— a-b: a=a.subtract(b);
乘—— a*b: a=a.multiply(b);
除—— a/b: a=a.divide(b);
求余—a%b: a=a.mod(b);
转换—a=b: b=BigInteger.valueOf(a);
比较 if (ans.compareTo(x) == 0)//比较
System.out.println("相等");
System.out.println("a + b = "+ans_add); // 这里的‘+’ (第二个) 是连接的意思
2. Python处理大数可以直接进行加减乘除,不过要注意时间问题,可作为验证来使用。
列举STL常用的函数:
STL常用算法:https://blog.csdn.net/qq_41823684/article/details/98938988
(1)sort
(2)unique
(3)string相关的操作
(4)remove和erase移除元素
(5)序列反转reverse
(6)序列交换swap
(7)统计等于某值的容器元素个数count
(8)条件统计count_if
(9)查找容器元素find
(10)条件查找容器元素find_if
(11)子序列搜索search
(12)最后一个子序列搜索find_end
(13)元素复制copy
(14)元素变换transform
(15)替换replace
(16)条件替换replace_if
(17)n次填充fill_n
(18)随机生成n个元素generate
(19)操作容器中的每一个元素for_each
(20)条件移除remove_if
// 去除连续的元素
s.erase(unique(s.begin(), s.end()), s.end());
// 去除指定的元素(字符串中所有该元素)
s.erase(remove(s.begin(), s.end(), '0'),s.end());
// 去除首元素
s.erase(0, 1);
vector<vector<int>> v;
v.resize(r, vector<int>(c, 0));
①除以零;
②数组越界:int a[3]; a[10000000]=10;
③指针越界:int * p; p=(int *)malloc(5 * sizeof(int)); *(p+1000000)=10;
④使用已经释放的空间:int * p; p=(int *)malloc(5 *sizeof(int));free(p); *p=10;
⑤数组开得太大,超出了栈的范围,造成栈溢出。
(1)vector如果要随机访问进行赋值,则必须先分配空间;
(2)局部数组不能太太,否则会产生堆栈溢出;可以使用全局数组或者动态分配。
(3)可以使用long long int防止数据太小导致的问题;
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有