ACM2032
杨辉三角
Problem Description
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 1
1
1 1
1 2 1
比较流行的算法是:
#include<stdio.h>
int main()
{
int n,i,j,s[][];
while(scanf("%d",&n)!=EOF)
{
for(i=;i<n;i++)
{
for(j=;j<n;j++)
{ if(j==||i==j)
s[i][j]=;
else
s[i][j]=s[i-][j-]+s[i-][j];
}
}
for(i=;i<n;i++)
{
for(j=;j<=i;j++)
{
printf("%d",s[i][j]);
if(j<i)
printf(" ");
else printf("\n");
}
}
printf("\n");
}
return ;
}
但用这个算法也是可以的(由于时间的关系,等有空会上传这样算法的代码):
ACM2032的更多相关文章
随机推荐
- Linux下GPIO驱动(二) ----s3c_gpio_cfgpin();gpio_set_value();
首先来看s3c_gpio_cfgpin(); int s3c_gpio_cfgpin(unsigned int pin, unsigned int config) { struct s3c_gpio_ ...
- thinkphp 框架的学习(1) 扩展配置文件
在config.php里面写入 1:'LOAD_EXT_CONFIG' => array('SETTINGS' => 'settings'); 系统会判断是否有参数:LOAD_EXT_CO ...
- initialize or clean up your unittest within .net unit test
// Use ClassInitialize to run code before running the first test in the class [ClassInitialize()] pu ...
- cocos2dx Tab选项卡控件的实现
选项卡控件在游戏和应用中很是常见,但是cocostudio里并没有实现好的选项卡控件,于是自己封装了 一个,效果如下: 代码: TabUiControl.h #pragma once //std #i ...
- 图像混合学习。运用加权函数,学习opencv基础操作
{ cout<< } { cout<< } ,,logoImage.c ...
- delphi xe5 android 控制蓝牙
本文部分内容摘自: http://www.pclviewer.com/android/用以下代码中的接口实现控制蓝牙的开.关及详细信息 unit Androidapi.JNI.BluetoothAda ...
- 关于c++字符串的while(*temp++)
首先,上一段代码 static bool reverse_str(const char *str) { const char *temp=str; while(*temp++); temp-=; // ...
- textarea中的文字自动换行问题
在textarea中设置输入内容的自动换行,也是在CSS中设置word-wrap:break-word; 属性.需要额外注意的是textarea元素本身有一个warp属性,其取值含义如下: off:不 ...
- C#读取Excel五种方式的体会
原地址: http://blog.csdn.net/dapengbusi/article/details/38117817 http://blog.csdn.net/dapengbusi/articl ...
- POJ 3352 Road Construction (边双连通分量)
题目链接 题意 :有一个景点要修路,但是有些景点只有一条路可达,若是修路的话则有些景点就到不了,所以要临时搭一些路,以保证无论哪条路在修都能让游客到达任何一个景点 思路 :把景点看成点,路看成边,看要 ...
