1. double ceil(double x) 求大於 x 的最小的數,即向上取整函數 2.A 65 Z 90 a 97 z 122 3.字元串刪除 https://blog.csdn.net/yishizuofei/article/details/79059804 C++ string 字元串刪 ...
1. double ceil(double x)
求大於 x 的最小的數,即向上取整函數
#include<bits/stdc++.h> using namespace std; int main(){ long long n,m,a; cin>>n>>m>>a; long long s=ceil(m*1.0/a)*ceil(n*1.0/a); //或寫為 //long long s=((m+a-1)/a)*((n+a-1)/a); cout<<s<<endl; return 0; }
2.A 65 Z 90
a 97 z 122
3.字元串刪除
https://blog.csdn.net/yishizuofei/article/details/79059804
C++ string 字元串刪除指定字元https://blog.csdn.net/lynn_xl/article/details/89151535
C++從string中刪除所有的某個特定字元 https://www.cnblogs.com/7z7chn/p/6341453.html 超好
#include<bits/stdc++.h> using namespace std; int main(){ string str; cin>>str; str.erase(remove(str.begin(),str.end(),'a'),str.end()); cout<<str<<endl; return 0; }
刪除特定字元串簡單做法
int pos=0;//下標 while( (pos=str.find("WUB"))!=-1 ){ str.erase(pos,3); }
5. 字元串 大寫 改為 小寫
for(int i=0;i<str.size();i++){ str[i]=tolower(str[i]); }
小寫改為大寫
toupper();
6.字元串 str1 中是否有字元字串 str2
strstr()函數
extern char *strstr(char *str1, char *str2);
作用:返回str2 在str1中第一次出現的位置(地址)
c_str() 函數
作用:c_str()函數返回一個指向正規C字元串的指針, 內容與本string串相同.,
這是為了與c語言相容,在c語言中沒有string類型,故必須通過string類對象的成員函數c_str()把string 對象轉換成c中的字元串樣式。
string str; string str2="1111111"; if(strstr(str.c_str(),str2.c_str())!=NULL)flag=true; else flag=false;
7.字元串插入字元
https://blog.csdn.net/wang1997hi/article/details/78364755
http://codeforces.com/problemset/problem/208/A
cf 208 A 考察了刪除和插入
str.insert(pos,str2);
cf 208 A
#include<bits/stdc++.h> using namespace std; int main(){ string str; cin>>str; int pos=0;//下標 while( (pos=str.find("WUB"))!=-1 ){ str.erase(pos,3); if(str[pos-1]!=' '&&pos!=0)str.insert(pos," "); } cout<<str<<endl; return 0; } str.insert(pos,str2);View Code