string 取出其中一个是字符
string s;
char a = s[0];
- string 找
int string.find_first_of("ab",index);
int string.find_last_of("qw",index);
int string.find_first_not_of("ab",index);
int string.find_last_not_of("qw",index);
size_t a = string.find_first_of("ab",index);
if(a == string::npos) //没找到
返回返回index,-1没找到
-
编写函数,传入数组等,注意为空的情况
-
scanf
scanf("%d%d ",&a,&b); // 后面多了个空格,会导致输入错误
scanf("%d%d",&a,&b); //正常的两个输入
scanf 有返回值
if(1 != scanf())
return -1;
- string 数字 char[]
- string 转char[]
string s ="aa";
const char *a = s.data();// must add cosnt
- char[] 转string
char a[] ;
string s =a;
- 数字转char[]
char p[10];
sprintf(p,"%d",1);
int a =10;
char b[] ="12";
itoa(a,b,2); // 2进制
cout<<b; //1010
- char[] 转数字
int a =10;
char b[] ="12";
sscanf(b,"%d",&a);
cout<<a; // 12
- 数学公式
#include <stdlib.h>
abs
-
codeblock debug 失败,工程路径含中文
-
scanf double
double a;
scanf("%lf",&a); // if
-
多项式求和,系数为0 ,则要舍去
-
结构体
c中
typedef struct s{
int i;
} SS;
SS a;
c++中
struct S{
int i;
};
typedef S SS;
int main(){
S s ; // object
SS ss; // pointer
ss = &s;
s.i=2;
}
- 四舍五入