31 Aralık 2012 Pazartesi

計算成績

某一學生修國文、計算機概論、計算機程式設計三科,
使用者輸入名字(一個char)、學號(integer)、三科成績(double)。
(1) 計算學生總成績、平均。
(2) 印出名字、學號、總成績、平均。

Input

K
905067
100
100
100

Output

Name: K
Id: 905067
Total: 300
Average: 100



  1. #include <stdio.h>    
  2. #include <stdlib.h>    
  3. #include <math.h>   
  4. int main()    
  5. {    
  6.   char name;     
  7.   int id,total,average;    
  8.   double  chinese, compscience, programming,avg,to,avgint;     
  9.   scanf("%c ",&name);      
  10.   scanf("%d",&id);    
  11.   scanf("%lf",&chinese);    
  12.  scanf("%lf",&compscience);    
  13.   scanf("%lf", &programming);    
  14.   to = (programming + chinese + compscience);  
  15.   total=to;    
  16.   to=to/3;  
  17.   avgint=floor(to);  
  18.   if(to-avgint>0.5) avg=ceil(to);    
  19.   else avg=to;  
  20.   average=avg;  
  21.            printf("Name:%c\n", name);    
  22.            printf("Id:%d\n", id);    
  23.            printf("Total:%d\n", total);    
  24.            printf("Average:%d\n", average);    
  25.   system("PAUSE");      
  26.   return average;    
  27. }  

Hiç yorum yok:

Yorum Gönder

Binary Conversion

Problem Description Convert two binary numbers into two decimal numbers and compute their sum. Your program has to convert two binary number...