Created
February 4, 2015 03:12
-
-
Save shohan4556/3933bb3b390c783a82c4 to your computer and use it in GitHub Desktop.
URI 1217 Solution in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// Author : MD.Shohanur Rahaman | |
| // URI 1217--Getline Two - Fruits | |
| #include<stdio.h> | |
| #include<string.h> | |
| int main() | |
| { | |
| float amt,avgtk,avgkg,total=0.0,t1; | |
| int day; | |
| int i,a,count=0,l; | |
| char name[10000]; | |
| while(scanf("%d",&day)==1){ | |
| total=0.0; | |
| count=0; | |
| a=0; | |
| t1=0; | |
| for(l=1;l<=day;l++){ | |
| scanf("%f",&amt); | |
| total=amt+total; | |
| getchar(); | |
| gets(name); | |
| for(i = 0; name[i] != '\0'; i++){ | |
| if(name[i] == 32) | |
| count++; | |
| } | |
| a=count+1; | |
| printf("day %d: %d kg\n",l,a); | |
| t1=a+t1; | |
| count=0; | |
| } | |
| avgtk= (float) (total/day); | |
| avgkg=(float) (t1/day); | |
| printf("%.2f kg by day\n",avgkg); | |
| printf("R$ %.2f by day\n",avgtk); | |
| } | |
| return 0; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment