#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<functional>
#include<algorithm>
int a[45];
sort(a,a+n);
while (isdigit(ch))
d=(d<<3)+(d<<1)+ch-48,ch=getchar();
#include<string.h>
memset
<xfunctional>
greater和less
scanf("%d%*c%d%d%d",&hour,&minutm,&id,&num);
“*”符:用以表示该输入项,读入后不赋予相应的变量,即跳过该输入值。
b="";
b+=ch[i];
gets(ch);
string str;
str.push_back('d');
pop_back() //移除最后一个元素
empty() //判断vector是否为空,如果返回true为空
erase() // 删除指定元素
string a,b;
map<string,string> mp;//键值对mp
cin>>a;//输入START
while(cin>>a&&a!="END"){
cin>>b;
mp[b]=a;//mp[Martian's language] = English
}
cin>>a;//输入END
getchar(); //吸收回车
char ch[3005];
while(1){
gets(ch);
int i,len;
if(strcmp(ch,"END")==0)
break;
len=strlen(ch);
b="";
for(i=0;i<len;++i){
if(ch[i]<'a'||ch[i]>'z'){
//输出字母或单词
if(mp[b]!="")//mp[b] != null
cout<<mp[b];//输出English
接受一个字符串,遇“空格”、“TAB”、“回车”都结束
char a[20];
cin>>a;
cout<<a<<endl;
输入:jkljkljkl
输出:jkljkljkl
输入:jkljkl jkljkl //遇空格结束,所以不能输入多个单词
输出:jkljkl
给定n个可连乘的矩阵{A1, A2, …,An},根据矩阵乘法结合律,可有多种不同计算次序,每种次序有不同的计算代价,也就是数乘次数。例如给定2个矩阵A[pi,pj]和B[pj,pk],A×B为[pi,pk]矩阵,数乘次数为pi×pj×pk
struct node
{
int fir,sec;
void Read() {scanf("%d %d",&fir,&sec);}
}input;
//结构体里可以有void函数,函数里可以用scanf
struct cmp1
{
bool operator () (const node &x,const node &y) const
{
return x.fir<y.fir;
}
};
priority_queue<node,vector<node>,cmp1> q1;
//结构体内置函数
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++) input.Read(),q1.push(input);
while(!q1.empty()) printf("%d,%d",q1.top().fir,q1.top().sec),q1.pop();
}
//快读
int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{if(ch=='-')f=-1;ch=getchar();}
while('0'<=ch && ch<='9')
{x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
return x*f;
}
memset(b,0x3f(无穷大)或者0或者-1,sizeof(b));
for循环的时候输出空格和回车
printf("%d%c",a[i].num,i==n-1?'\n':' ');
函数名: ceil
用 法: double ceil(double x);
功 能: 返回大于或者等于指定表达式的最小整数
头文件:math.h
返回数据类型:double
矩阵由空格分隔的小写字母组成
char s[2];
scanf("%s",s);
scanf("%[^\n]",&str);
printf("%s\n",str);
essential
最新推荐文章于 2024-07-24 21:35:38 发布