题解 | #杨辉三角的变形#

杨辉三角的变形

http://www.nowcoder.com/practice/8ef655edf42d4e08b44be4d777edbf43

#include<iostream>
#include<string>
using namespace std;
int main(int argc,char* argv[])
{
    int nRow=0;
    while(cin>>nRow)
    {
        int res=-1;
        int myInt[]={4,2,3,2};
        if(nRow>2)
            res=myInt[(nRow-2)%4];
        cout<<res<<endl;
    }
    return 0;
}
//分析思路:
//                                          1
//                                     1    1    1
//                                1    2    3      2      1
//                           1    3    6     7     6      3    1
//                      1    4    10   16    19    16    10    4    1
//                  1   5    15   30   45    51    45    30    15    5    1
//              1   6   21   50   90   126   141   126   90    50    21   6    1
//          1   7   28  77
//      1   8   36  112
//  1   9   51  156
//  10  
//通过以上的数据分析规律为 {-1,-1,2,3,2,4,2,3,2,4,...}
全部评论

相关推荐

12-15 11:27
门头沟学院 Java
哇哇的菜鸡oc:所有人不要理会,就好了,后面他就知道怎么回事了,只能说有的时候市场都是被宰的人搞坏的
点赞 评论 收藏
分享
评论
9
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务