2014江西理工大学C语言程序竞赛初级组

坐公交

解法:略

 #include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<time.h>
#include <stdlib.h>
#include<algorithm>
using namespace std;
int main()
{ int a,b,c;
while(cin>>a>>b>>c)
{
cout<<min({a,b,c})<<endl;
}
return ;
}

初见

解法:模拟

#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
int k;
while(~scanf("%d",&k))
{
int i=;
double sum=;
while(sum<k)
{
i++;
// cout<<sum<<endl;
sum+=(double)/i*(1.0); }
printf("%d\n",i);
}
return ;
}

问卷调查

解法:模拟

#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<time.h>
#include <stdlib.h>
#include<algorithm>
using namespace std;
struct P
{
double x;
// string s;
// int pos;
}He[][];
int main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
int n,m;
while(cin>>n>>m)
{
string s[];
for(int i=;i<n;i++)
{
cin>>s[i];
}
for(int i=;i<m;i++)
{
int xa=,xb=,xc=,xd=;
for(int j=;j<n;j++)
{
if(s[j][i]=='A')
{
xa++;
}
else if(s[j][i]=='B')
{
xb++;
}
else if(s[j][i]=='C')
{
xc++;
}
else if(s[j][i]=='D')
{
xd++;
}
}
// cout<<xa<<" "<<xb<<" "<<xc<<" "<<xd<<endl;
He[i][].x=(double)xa/(xa+xb+xc+xd);
He[i][].x=(double)xb/(xa+xb+xc+xd);
He[i][].x=(double)xc/(xa+xb+xc+xd);
He[i][].x=(double)xd/(xa+xb+xc+xd);
}
for(int i=;i<m;i++)
{
for(int j=;j<;j++)
{
if(j==)
{
printf("%.2f",He[i][j].x);
}
else
{
printf(" %.2f",He[i][j].x);
}
}
puts("");
}
}
return ;
}
上一篇:STM32 USB音频麦克风实现


下一篇:HDU 5033 Building(单调栈)