有些函数可以用来确定数组中的值总数及唯一值的个数。使用函数count()对元素个数进行统计,sizeof()函数时count()的别名,他们的功能是一样的。
分类:
其他好文 时间:
2014-08-08 15:32:46
阅读次数:
371
知识点:字符函数 strlen()的用法ASCLL码与数字的转换,-48数组的灵活用法,数组名的用法。char a[100]; int i,s=0,m; scanf("%s",&a); m=strlen(a);内容: 求输入的一个整数的各位数字之和输入说明:一行一个整数输出说明:一个整数输入样例:2...
分类:
其他好文 时间:
2014-08-08 15:12:46
阅读次数:
225
代码:
#include
using namespace std;
/*
class a{
float k; // 4字节
virtual void foo(){} //有一个4字节的指针指向自己的虚函数表
};
class b : virtual public a{
virtual void f(){}
}; 有这样的一个指针vptr_b_a,这个指针叫虚类指针,也是四个字节...
分类:
其他好文 时间:
2014-08-07 23:23:25
阅读次数:
465
void GetNextval(char* p, int next[])
{
int pLen = strlen(p);
next[0] = -1;
int k = -1;
int j = 0;
while (j < pLen - 1)
{
//p[k]表示前缀,p[j]表示后缀
...
分类:
其他好文 时间:
2014-08-07 19:12:11
阅读次数:
229
Manacher算法o(n)求解最长回文子串问题 非常巧妙
#include
using namespace std;
char str[2000020],s[2000020];
int p[2000020];
int len,id,mx;
void pre() //对字符串进行预处理
{
len=strlen(s);
str[0]='$';
str[1]='#';...
分类:
其他好文 时间:
2014-08-07 09:50:39
阅读次数:
237
<?php
header(‘Content-Type:text/html;charset=utf-8‘);
functioncutstr($str,$len){
if($len<0){returnnull;}
$chars=0;//字符数量
$offset=0;
$res=‘‘;
while($chars<$len){
$high=decbin(ord(substr($str,$offset,1)));
if(strlen($high)<8){
$count=1;
}els..
分类:
Web程序 时间:
2014-08-07 07:39:10
阅读次数:
265
#include
typedef union{
long x[2];
int y[4];
char z[8];
}MYTYPE;
MYTYPE them;
main()
{
printf("%d\n",sizeof(them));
}...
分类:
其他好文 时间:
2014-08-06 23:14:42
阅读次数:
251
#include #include #include int main(){ int T; scanf("%d",&T); while(T--) { int max=0,k,l,i; char a[1020]; int b[27]={0}; scanf("%s",a); l=strlen(a); f...
分类:
其他好文 时间:
2014-08-06 22:39:36
阅读次数:
194
问题:最后一个单词的长度分析,注意s=" a b "这种情况,从后遍历单词,遇到空格退出class Solution {public: int lengthOfLastWord(const char *s) { int len=strlen(s); int sum=...
分类:
其他好文 时间:
2014-08-06 22:02:22
阅读次数:
209
最近玩儿python玩上瘾了,突然想念c语言,所以,休闲下:解法一:如果没有对申请外部空间有所限制,那就先试试这个喽:1 void invert_str1(char *old_str, char *new_str)2 {3 int i = strlen(old_str)-1;4 in...
分类:
其他好文 时间:
2014-08-06 18:12:01
阅读次数:
206