矩阵找最大值

题目描述

给定一个n * n矩阵a,满足条件:

①对于所有1≤i≤n,ai,1 = a1,i = 1

②在①条件之外的位置,每个位置的值均等于它上面的值与左面的值的和。

请你找到矩阵中最大的数字是多少。

Given a n*n matrix A, which satisfies the conditions:

①for all the position of ai,if 1≤i≤n,ai,1 = a1,i = 1

②beyond the condition ①, each value of the position is equal to the sum of the value of above posotion and the value of left position.

Please find out the largest number in the matrix.

输入

一个整数n,代表矩阵规模。(1≤n≤10)

an integer n, which represents the  scale of the matrix.(1≤n≤10)


输出

一个整数ans,表示矩阵中的最大数字。

an integer ans, which represents the largest number in the matrix.

样例输入

5

样例输出

70

提示

来源


#include <stdio.h>
#include <stdlib.h>
int main() {
int n, a[10][10], i, j;
while(scanf("%d",&n)!= EOF){
for (i = 1; i <= n; i++) {
for(j = 1; j <= n; j++) {
if (i == 1 || j == 1)
a[i][j] = 1;
else 
a[i][j] = a[i-1][j] + a[i][j-1];
}

}
printf("%d\n", a[n][n]);
}


return 0;
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值