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

普普通通一个人

文章分类

全部博文(102)

文章存档

2018年(1)

2015年(13)

2014年(88)

我的朋友

分类: C/C++

2014-01-20 17:30:07


点击(此处)折叠或打开

  1. #include <stdio.h>
  2. int main(){
  3.     /* declaration and initialize the variable */
  4.     int i_basenumber = 0, i_power = 0, i_tmp_base, i_tmp_power;
  5.     /* prompt */
  6.     printf("Enter the base number: ");
  7.     scanf("%d", &i_basenumber);
  8.     printf("Enter the power: ");
  9.     scanf("%d", &i_power);
  10.     /* assignment the base number to tmp variable */
  11.     i_tmp_base = i_basenumber;
  12.     /* assignment the power number to tmp variable */
  13.     i_tmp_power = i_power;

  14.     /* calculate the power */
  15.     while(i_tmp_power - 1 > 0 ){
  16.         i_basenumber = i_tmp_base * i_basenumber;
  17.         i_tmp_power--;
  18.     }
  19.     /* output the result */
  20.     printf("The result is: %d\n", i_basenumber);

  21.     return 0;
  22. }

阅读(197) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~