

该学习了。。。
这个程序 CASE "F" OR "B" 时也应该考虑500miles问题 考虑他们加上奖励值后仍然小于500miles 的情况
#include<stdio.h>
#include<string.h>
int main()
{
#ifndef ONLINE_JUDGE
freopen ("Mileage Bank.txt","r",stdin);
#endif
char str1[50],c;
double Mile,sum=0;
while(EOF!=(scanf("%s",str1)))
{
if(strcmp(str1,"#")==0)
{
break;
}
if(strcmp(str1,"0")!=0)
{
scanf("%s",str1);
scanf("%lf",&Mile);
getchar();
scanf("%c",&c);
switch(c)
{
case 'F':sum+=Mile*2;break;
case 'B':sum+=Mile*1.5;break;
case 'Y':if(Mile<500)sum+=500;
else sum+=Mile;break;
}
}
else
{
printf("%.lf\n",sum);
sum=0;
}
}
return(0);
}
貌似我只能做到这样了..
#include <stdio.h>
#include <string.h>
#define N 100
struct jilu
{
char chufa[20];
char mudi[20];
long int licheng;
char leibie;
}persen[N];
void main()
{
int i,j,sum=0;
double miles[100];
printf("出发地\t目的地\t实际航行里程\t类别代码\n");
do
{
for(i=0;i<N;i++)
{
fflush(stdin);
gets(persen[i].chufa);
if(strcmp(persen[i].chufa,"0")==0||strcmp(persen[i].chufa,"#")==0)
break;
else
{
fflush(stdin);
gets(persen[i].mudi);
scanf("%ld,%c",&persen[i].licheng,&persen[i].leibie);
if(persen[i].leibie=='f'||persen[i].leibie=='F')
miles[i]=persen[i].licheng*2;
else if(persen[i].leibie=='b'||persen[i].leibie=='B')
miles[i]=persen[i].licheng*1.5;
else if(persen[i].leibie=='y'||persen[i].leibie=='Y')
{
if(persen[i].licheng>=500)
miles[i]=persen[i].licheng;
else
miles[i]=500;
}
}
}
for(j=0;j<i;j++)
{
printf("奖励点数为:%9.0f\n",miles[j]);
sum=sum+(int)miles[j];
}
printf("总分为:%d\n",sum);
}while(strcmp(persen[i].chufa,"#")!=0);
}
还有如提示这样输出不知道..求教...
样本输入 样本输出
北京 东京 1329 F
上海 武汉 433 Y
这又是一次作业!!
Binomial Showdown
In how many ways can you choose k elements out of n elements, not taking order into account?
Write a program to compute this number.
Input
The input will contain one or more test cases.
Each test case consists of one line containing two integers n (n >= 1) and k (0 <= k <= n).
Input is terminated by two zeroes for n and k.
Output
For each test case, print one line containing the required number. This number will always fit into an integer, i.e. it will be less than 231.
Sample Input
4 2
10 5
49 6
0 0
Sample Output
6
252
13983816