训练1
来源:互联网 发布:本坦库尔fm数据 编辑:程序博客网 时间:2024/04/30 06:18
气球颜色
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
char color[1000][16];
int math[1000];
int main()
{ int i;
while(scanf("%d",&i)!=EOF&&i!=0)
{ memset(math,0,1000*sizeof(int));
int flag1=i;
for(int j=0;j<i;j++)
{
scanf("%s",&color[j]);
for(int k=0;k<j;k++)
{
if(strcmp(color[k],color[j])==0&&j!=0)
{
math[k]=math[k]+1;
//cout<<"a"<<math[k]<<endl;
} }}
int max=0;
int flag=0;
for(int j=0;j<flag1;j++)
{ if(math[j]>max)
{
max=math[j];
flag=j;
}
}
/* for(int j=0;j<flag1;j++)
{ cout<<math[j]<<endl;
}
for(int j=0;j<i;j++)
{
cout<<color[j]<<endl;
}*/
cout<<color[flag]<<endl;
}
}
士兵队列
#include<stdio.h>
#include<string.h>
using namespace std;
char color[1000][16];
int math[5008];
{
int z,k,m;
while(z--)
{
scanf("%d",&k);
int sum=k;
if(sum<=3)
{
cout<<"1";
for(int i=2;i<=sum;i++)
cout<<" "<<i;
cout<<endl;
continue;
}
for(int i=1;i<=k;i++)
{
math[i]=i;
}
/* for(int i=1;i<=k;i++)
{
cout<<math[i];
}*/
while(1)
{ //cout<<"456";
int flag=0;
for(int i=1;i<=k;i++)
{
if(math[i])
flag++;
if(flag==2)
{
math[i]=0;
flag=0;
sum--;
}
}
{
break;
}
int flag1=0;
for(int i=1;i<=k;i++)
{
if(math[i])
flag1++;
if(flag1==3)
{
math[i]=0;
flag1=0;
sum--;
}
}
{
break;
}
}
//cout<<sum;
cout<<"1";
sum--;
for(int i=2;sum>0;i++)
{
if(math[i])
{
cout<<" "<<math[i];
sum--;}
}
cout<<endl;
}
}
#include<stdio.h>
#include<string.h>
using namespace std;
char math[1001];
int main()
{
int i;
scanf("%d",&i);
getchar();
while(i--)
{
//memset(math,'1', sizeof(math));
gets(math);
//getchar();
//cout<<math<<endl;
int x=strlen(math);
// cout<<x<<endl;
int flag=0;
int flag1=-1;
int sum=-1;
for(int i=0;i<=x;i++)
{
if((math[i]==' ')&&(i!=x))
{
flag1=i;
sum=i-flag;
flag=i+1;
int j=i;
for( int k=sum;k>0;k--)
{
j--;
printf("%c",math[j]);
}
}
if(math[i]==' ')
{ printf(" ");
}
//cout<<"sssssssss"<<flag1;
if(i==x)
{ sum=i-flag;
int j=i;
for( int k=sum;k>0;k--)
{
j--;
printf("%c",math[j]);
}
}
}
printf("\n");
}
return 0;
}
#include<iostream>
#include<vector>
#include<stdio.h>
#include<functional>
#include <cstdlib>
#include<string.h>
//0051231232050775
char a[1000000000];
using namespace std;
typedef long long int LL;
int main()
{ long long int flag=0,x=0,ze;
priority_queue<LL,vector<LL>,greater<LL> >p1;
while(scanf("%s",a)!=EOF)
{
for(int i=0;a[i]!='\0';i++)
{ if(a[i]==0&&flag==0)
{
flag=1;
continue;
}
if(a[i]=='5'&&i==0)
{
continue;
}
if(a[i]=='5'&&i!=0)
{
if(a[i]=='5'&&a[i-1]=='5')
{ continue;
}
else
{p1.push(x);
x=0;//cout<<x<<endl;
continue;
}
}
ze=a[i]-'0';
x=x*10+ze;
//cout<<x<<endl;
}
{
p1.push(x);
}
ze=p1.top();
cout<<ze;
p1.pop();
while(!p1.empty())
{ ze=p1.top();
cout<<" "<<ze;
p1.pop();
}
cout<<endl;
}
}
#include<iostream>
#include<vector>
#include<stdio.h>
#include<functional>
#include <cstdlib>
#include<string.h>
//0051231232050775
using namespace std;
typedef long long LL;
int main()
{
int x,y,za,zc;
char c;
while(cin>>x>>y)
{ priority_queue<LL,vector<LL>,greater<LL> >p1;
while(x--)
{ cin>>c;
if(c=='Q')
{
za=p1.top();
cout<<za<<endl;
}
else
{cin>>zc;
p1.push(zc);
if(p1.size()>y)
{ p1.pop();
}
}
}
}
return 0;
}
#include<stdio.h>
#include<string.h>
using namespace std;
char a[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
char b[100000000];
char c[100000000];
{
while(1)
{
int x=-1,y=-1,flag=1,t1=0,t2=0;
while(scanf("%s",b))
{
// cout<<b<<x<<" "<<y<<endl;
//three four + five six =
if(b[0]=='=')
{ if(x==0&&y==0)
break;
else{
cout<<x+y<<endl;
break;
}
}
if(b[0]=='+')
{
flag=0;
// cout<<"rilegou"<<endl;
}
{
for(int i=0;i<=9;i++)
{
if(strcmp(a[i],b)==0)
{ if(t1==0)
{x=i;
t1++;}
else
x=x*10+i;
// cout<<a[i]<<x<<"xxxx"<<endl;
}
}
}
if(flag!=1&&b[0]!='+')
{
for(int i=0;i<=9;i++)
{
if(strcmp(a[i],b)==0)
{if(t2==0)
{y=i;
t2++;
}
else
y=y*10+i;
//cout<<a[i]<<y<<"xxxx"<<endl;
}
//cout<<"rilegou"<<endl;
}
}
}
if(x==0&&y==0)
break;
//cout<<x<<y<<endl;
}
return 0;
}
- 训练1
- 训练1-1
- BPN训练1
- 训练营1
- JAVA训练1
- 矩阵专题训练1
- QUST每周训练1
- 蓝桥杯训练1
- 陪猪训练1。。。
- PAT训练(1)
- FastRCNN 训练-1
- 训练1-2
- 训练1-3
- 训练1-4
- 训练1-5
- 训练3 习题1
- Struts2 入门训练1
- 训练4 习题1
- 变峰驼名
- android开发之android:process属性
- springMVC校验器配置
- java的增强性for循环(foreach)访问数组
- python字典(Dictionary)-整理
- 训练1
- 解析BeanDefinition之解析子元素replaced-method
- CVPR 2016 全部文章摘要阅读
- linux系统的用户和用户组简介
- 触发器优缺点
- [OpenCV]拓展图像边界
- (九) 两个Model之JSONModel
- opencv示例程序
- Opencv各个模块功能详细简介