a expample of the c programming language.(temp)
2005-01-05 22:22
507 查看
#include <stdio.h>
int main()
{
int row_amount, column_amount; //定义需要输出的行数和列数.
int i, j; //定义循环变量
int nSquare(int,int); //声明函数:返回x的y次方结果;
//输入需要打印的行数和列数.
printf("Please input amount of ROWS(int) to printout:");
scanf("%d",&row_amount);
printf("Please input amount of COLUMNS(int) to printout:");
scanf("%d",&column_amount);
//输出结果:一行一行输出 ;
for (i=1;i<=row_amount;i++)
{
for (j=1;j<=column_amount;j++)
printf("%10d",nSquare(i,j));
printf("/n"); //一行打印完毕后换行.
}
return 0;
}
//定义函数 nSquare();
//作用: 返回x的y次方结果;
//参数: (int)x, (int)y ;
//返回值: (int)result;
int nSquare(int x, int y)
{
int result = 1; //函数返回值,初始化为1.
int i; //循环变量
for (i=1;i<=y;i++)
result = result * x;
return result;
}
int main()
{
int row_amount, column_amount; //定义需要输出的行数和列数.
int i, j; //定义循环变量
int nSquare(int,int); //声明函数:返回x的y次方结果;
//输入需要打印的行数和列数.
printf("Please input amount of ROWS(int) to printout:");
scanf("%d",&row_amount);
printf("Please input amount of COLUMNS(int) to printout:");
scanf("%d",&column_amount);
//输出结果:一行一行输出 ;
for (i=1;i<=row_amount;i++)
{
for (j=1;j<=column_amount;j++)
printf("%10d",nSquare(i,j));
printf("/n"); //一行打印完毕后换行.
}
return 0;
}
//定义函数 nSquare();
//作用: 返回x的y次方结果;
//参数: (int)x, (int)y ;
//返回值: (int)result;
int nSquare(int x, int y)
{
int result = 1; //函数返回值,初始化为1.
int i; //循环变量
for (i=1;i<=y;i++)
result = result * x;
return result;
}
相关文章推荐
- Selected solutions to exercise of "The C Programming Language" 2e (Part 5)
- Types and Declarations(Chapter 4 of The C++ Programming Language)
- Which of the following statement(s) equal(s) value 1 in C programming language?
- Selected solutions to exercise of "The C Programming Language" 2e (Part 6)
- The Survey of Programming Language Classification
- Pointers, Arrays, and Structures(Chapter 5 of The C++ Programming Language)
- 为什么JavaScript有能力成为未来企业级编程语言?Why JavaScript Will Become The Dominant Programming Language Of The Ente
- The C Programming Language——Exercise solutions of the chapter one (1st)
- Selected solutions to exercise of "The C Programming Language" 2e (Part 7, End of Chapter 1)
- A Tour of the Standard Library(Chapter 3 of The C++ Programming Language)
- Source Files and Programs(Chapter 9 of The C++ Programming Language)
- Selected solutions to exercise of "The C Programming Language" 2e (Part 1)
- Functions(Chapter 7 of The C++ Programming Language)
- Notes to the Reader(Chapter 1 of The C++ Programming Language)
- Templates(Chapter 13 of The C++ Programming Language)
- Selected solutions to exercise of "The C Programming Language" 2e (Part 2)
- A Tour of C++(Chapter 2 of The C++ Programming Language)
- Selected solutions to exercise of "The C Programming Language" 2e (Part 3)
- The kayword "new" of CPP programming language
- Objective-C has won the TIOBE programming language award of 2011