| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:黏贴代码,求解释,提交编译错误,与输出时候的小数.0有关?In Reply To:黏贴代码,求解释,提交编译错误,与输出时候的小数.0有关? Posted by:hywwqq at 2012-04-05 11:55:32 > #include<stdio.h>
> #include <string.h>
> #define N 10
> struct {
> int s;
> char name[N];
>
> }room[N];
> void main()
> {
> int n;
> float sum1=0;int sum2=0,sum=0,p;
> scanf("%d %d",&n,&p);
>
> for(int i=0;i<n;i++)
> scanf("%d %s",&room[i].s,room[i].name);
>
> for(i=0;i<n;i++)
> sum+=room[i].s;
> printf("%d\n",sum);
> sum1=(float)sum;
> for( i=0;i<n;i++)
> {
> if(strcmp("balcony",room[i].name)==0)
> sum1=sum1-(float)room[i].s/2;
> if(strcmp("bedroom",room[i].name)==0)
> sum2=sum2+room[i].s;
> }
>
> printf("%d\n",sum2);
> printf("%.1f",sum1*(float)p);
>
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator