1.
#include
int main()
{
int n;
char s[5];
scanf("%d%s",&n,s);
if(s[0]=='M')
{
if(n>=70)
printf("250\n");
else
printf("200\n");
}
else
{
if(n>=60)
printf("180\n");
else
printf("150\n");
}
return 0;
}
体重70公斤及以上,献血250ml,70公斤及以下200ml。
那么70公斤到底是多少?
2.
#include
int main()
{
int a,b,c,x=0,y=0;
scanf("%d%d%d",&a,&b,&c);
x=a*100+b*50+c*10;
y=x%100;
x/=100;
printf("Dollars=%d\nChange=%d\n",x,y);
return 0;
}
题目叙述对70公斤男与60公斤女有些问题。
1.#include
int main(){
int w=0;char c;
c=getchar();
while ( (c<='9') && (c>='0') ) {
w*=10;
w+=int(c-'0');
c=getchar();
}
if (c='M') {
if (w>=70) printf("250");
else printf("200");
}
else {
if (w>=60) printf("180");
else printf("150");
}
return(0);
}
2.
#include
int main(){
int i,j,k;
int z,l;
scanf("%d%d%d",&i,&j,&k);
z=(100*i+50*j+10*k)/100;
l=(100*i+50*j+10*k)%100;
printf("Dollars=%d\n",z);
printf("Change=%d\n",l);
return(0);
}
第一题:
#include
#include
void main()
{
int a;
char b;
cin>>a>>b;
if (b=='M')
{
if (a>=70)
{
cout<<250;
}
else cout<<200;
}
if (b=='F')
{
if (a>=60)
{
cout<<180;
}
else cout<<150;
}
}
1. 代码如下:
#include
#include
using namespace std;
main()
{
string str;
int weight=0,i,j=1;
cin >> str;
for(i=str.size()-2;i>=0;i--)
{
weight += (str[i]-'0')*j;
j*=10;
}
if(str[str.size()-1] == 'M')
{
if(weight>=70) cout << 250 << endl;
else cout << 200 << endl;
}
else
{
if(weight>=60) cout << 180 << endl;
else cout << 150 << endl;
}
}
2. 代码如下:
#include
using namespace std;
main()
{
int yuan, jiao_5, jiao_1, dollar, change;
cin>>yuan>>jiao_5>>jiao_1;
dollar = yuan + (jiao_5*5+jiao_1)/10;
change = (jiao_5*5+jiao_1)%10;
cout << "Dollars=" << dollar << endl;
cout << "Change=" << change*10 << endl;}