Chinaunix首页 | 论坛 | 博客
  • 博客访问: 99243
  • 博文数量: 102
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1011
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-15 13:58
个人简介

普普通通一个人

文章分类

全部博文(102)

文章存档

2018年(1)

2015年(13)

2014年(88)

我的朋友

分类: C/C++

2014-01-15 14:40:36


点击(此处)折叠或打开

  1. /* Calculation three integers + * largest smallest */
  2. /* Input: three integers */
  3. /* Output:
  4. the sum is:
  5. the product is:
  6. the average is
  7. the largest is:
  8. the smallest is:
  9. */
  10. #include<stdio.h>
  11. int main(){
  12.     /* declaration */
  13.     int int_input_first_integer, int_input_second_integer, int_input_third_integer;
  14.     /* declaration */
  15.     int int_temp_a, int_temp_b;
  16.     /* prompt */
  17.     printf("Please Enter three integers:");
  18.     /* input three integers */
  19.     scanf("%d%d%d", &int_input_first_integer, &int_input_second_integer, &int_input_third_integer);
  20.     /* assign the sum */
  21.     printf("The sum is: %d\n", int_input_first_integer + int_input_second_integer + int_input_third_integer);
  22.     /* assign the product */
  23.     printf("The product is: %d\n", int_input_first_integer * int_input_second_integer * int_input_third_integer);
  24.     /* assign the average */
  25.     printf("The average is: %d\n", (int_input_first_integer + int_input_second_integer + int_input_third_integer)/3);
  26.     
  27.     /* assign the larger between the first and the second integer to the a, and the smaller to the b */
  28.     if(int_input_first_integer >= int_input_second_integer){
  29.     int_temp_a = int_input_first_integer;
  30.     int_temp_b = int_input_second_integer;
  31.     }
  32.     else{
  33.         int_temp_a = int_input_second_integer;
  34.         int_temp_b = int_input_first_integer;
  35.     }
  36.     /* compare the a and the third integer */
  37.     if(int_temp_a >= int_input_third_integer){
  38.         printf("The largest is: %d\n", int_temp_a);
  39.     }
  40.     else{
  41.         printf("The largest is: %d\n", int_input_third_integer);
  42.     }
  43.     /* compare the b and the third integer */
  44.     if(int_temp_b >= int_input_third_integer){
  45.     printf("The smallest is: %d\n", int_input_third_integer);
  46.     }
  47.     else{
  48.         printf("The smallest is: %d\n", int_temp_b);
  49.     }

  50.     /*examiation*/
  51.     printf("x=%d\ny=%d\nz=%d\n",int_input_first_integer, int_input_second_integer, int_input_third_integer);
  52.     printf("int_temp_a=%d\nint_temp_b=%d\n",int_temp_a, int_temp_b);

  53.     return 0;
  54. }


阅读(98) | 评论(0) | 转发(0) |
0

上一篇:三元表达式

下一篇:if嵌套 阶梯判断

给主人留下些什么吧!~~