Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:黏贴代码,求解释,提交编译错误,与输出时候的小数.0有关?

Posted by hellow_world at 2017-08-19 11:33:08 on Problem 4016
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator