zoukankan      html  css  js  c++  java
  • Coursera--DataStructure-加州理工大学圣地亚哥分校课程

    2017-12-03 20:59:12

    程序 = 数据结构 + 算法

    系统最核心的是数据  数据结构是将数据如何组织,就像택배 箱子的合理摆放;而算法则是 数据相互间如何的交互。

    在 coursera 上专门报了相关的课程。全英教学。几道题,折磨了周末的一个下午。

    其中有个 最大数对,记录一下:

    long long MaxPairwiseProduct(const verctor<int>& numbers){
        int n = numbers.size();
        
        int max_index1 = -1;
        for(int i = 0; i < n; ++i)
        if((max_index1 == -1) || (numbers[i] > numbers[max_index1]))
        max_index1 = i;
        
        int max_index2 = -1;
        for(int j = 0; j < n; ++j)
        if(( j != max_index1) && ((max_index2 == -1) || (numbers[j] > numbers[max_index2])))
        max_index2 = j;
        
        return ((long long)(numbers[max_index1])) * numbers[max_index2];
        
    }
  • 相关阅读:
    codeforces 980A Links and Pearls
    zoj 3640 Help Me Escape
    sgu 495 Kids and Prizes
    poj 3071 Football
    hdu 3853 LOOPS
    hdu 4035 Maze
    hdu 4405 Aeroplane chess
    poj 2096 Collecting Bugs
    scu 4444 Travel
    zoj 3870 Team Formation
  • 原文地址:https://www.cnblogs.com/masterSoul/p/7967339.html
Copyright © 2011-2022 走看看