#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define max 1000
const int max=100;
int main(int argc, char const *argv[])
{
return 0;
}
牛客网平台的OJ模式,要自己实现主函数对样例循环
leetcode不用考虑这些
int num=0;
string str;
//方式一
while(getline(cin,str))//不定量的输入需要使用getline(cin,str),否则会断流。
{ }
//方式二
while(cin>>num)
{
cin>>str;
}
//方式三
//scanf操作
unsigned int IP_cell[4];
while(scanf("%d.%d.%d.%d",&IP_cell[0],&IP_cell[1],&IP_cell[2],&IP_cell[3]) !=EOF)
{ }
//符号说明:
%d //输入十进制整数
%c //输入单个字符
%s //输入字符串
//IP转数值
//移位操作 和 与操作
unsigned int ip_2_num = IP_cell[0]<<24 | IP_cell[1]<<16 | IP_cell[2]<<8 | IP_cell[3];
//取余
int length = str.size();
int a = length/8; //8位分割
int b = length%8;
int num;
int a = num/2; //num二进制表示,然后右移1位的数字
int b = num%2; //num二进制表示,最右边一位数值 0 or 1
int num;
int a = num/10; //num十进制右移
int b = num%10; //num十进制最右边一位数值 0-9
//10转2进制
int num;
cin>>num;
while(num)
{
int b = num%2;
//b为最右边一位的数字,0 or 1
num/=2;
//相当于右移操作
}
//--四舍五入
float Num;
while (cin >> Num)
{
Num = (int)Num+(int)((Num-(int)Num)/0.5);
cout<
switch (cell[0])
{
case 'W':
cell.erase(0,1);
y+=atoi(cell.c_str()); //注意:str2int语句
break;
case 'S':
cell.erase(0,1);
y-=atoi(cell.c_str());
break;
case 'A':
cell.erase(0,1);
x-=atoi(cell.c_str());
break;
case 'D':
cell.erase(0,1);
x+=atoi(cell.c_str());
break;
default:
break;
}
case 'a': case 'b': case 'c': decode+='2'; break;//a或b或c的情况,写在一起
int num=0;
while (cin >> num)
{
int *Arry;
Arry = new int[num];
for(int i=0; i> Arry[i];
delete []Arry;
Arry = nullptr;
}
//--二维动态数组
//--动态数组已经可以这样去定义了
int main(){
int a;
cin>>a;
int b[a]={ 0,1,2,3 };
for (size_t i = 0; i < 4; i++)
cout<
class solution
{
private:
int a;
public:
int function(vector &nums)
{
}
};
int main(int argc, char const *argv[])
{
solution S;
vector v ={1,2,3};
int result = S.function(v);
return 0;
}
struct Astruct
{
private:
int a;
public:
int function(vector &nums)
{
}
};
int main(int argc, char const *argv[])
{
Astruct S;
vector v ={1,2,3};
int result = S.function(v);
return 0;
}
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
void deleteNode(ListNode* node) {
node->val = (node->next)->val;
node->next = node->next->next;
}
};
struct point{
int x;
int y;
point(int x, int y) : x(x), y(y) {}
bool operator == (const point & obj) const {
return x == obj.x && y == obj.y;
}
};
//字符串加密
void Encrypt (string& aucPassword, string& aucResult)
{
for (size_t i = 0; i < aucPassword.size(); i++){
if (aucPassword[i]<='9' && aucPassword[i]>='0')
//aucResult[i]= (aucPassword[i]+1)%10; //注意!!!aucResult地址,不可直接赋值元素i
aucResult += ((aucPassword[i]-'0'+1)%10 + '0');
}
}
//字符串解密
void unEncrypt (string& password, string& result)
int main()
{
string text,code;
while (cin >> text>> code)
{
string text2code, code2text;
Encrypt(text,text2code);
unEncrypt(code,code2text);
cout<
//伪回文
//找出现奇数次的数字,这种数字比较危险,必须放在中间
//如果这种数字有两个以及以上,不能构成伪回文
bool Solution::check(vector &path)
{
bool flag[10]={0};
int count=0;
for(size_t i=0; i &path)
{
for(size_t i=0;i
//–字符串单词截取,
string str;
vector Box;
while(getline(cin,str))
{
string words="";
for (size_t i = 0; i < str.size(); i++)
if ((str[i]>='a' && str[i]<='z') || (str[i]>='A'&&str[i]<='Z')) //接收到合格字符
words+=str[i];
else if(words.size()>0)
{
Box.push_back(words);
words="";
}
if(words.size()>0)
Box.push_back(words);
//for (size_t i = Box.size()-1; i>=0; i--) //注意这种写法是错的!!!,最后i=0的时候还会再计算一步i--
for (size_t i = Box.size(); i>1; i--)
cout<
//还有其他更好的方法啊:最开始就在string后面加上一个" "
int isPrefixOfWord(string sentence, string searchWord) {
sentence+=" ";
vector Box;
string words;
for(char c:sentence){
if(c==' '){
Box.push_back(words);
words="";
}
else
words+=c;
}
}