zoukankan      html  css  js  c++  java
  • [课程相关]homework-08

    一、变量作用域和生命周期

     1 #include <cstdlib>
     2 #include <iostream>  
     3 
     4 using namespace std;
     5 
     6 void try_change(int a){
     7     a = 20;
     8 }
     9 
    10 int main(int argc, char** argv) {
    11     int a = 10;
    12     try_change(a);
    13     cout<<a;
    14     return 0;
    15 }

    二、堆和栈

     1 #include <cstdlib>
     2 #include <iostream>  
     3 
     4 using namespace std;
     5 
     6 int *a;
     7 int *d;
     8 
     9 void try_both(){
    10     int *b = new int(100);
    11     int c = 200;
    12     a = b;
    13     d = &c;
    14 }
    15 
    16 
    17 int main(int argc, char** argv) { 
    18     try_both();
    19     cout<<*a<<endl;
    20     cout<<*d<<endl;
    21     return 0;
    22 }

    三、分解url

    为什么我要用Python写:

    1. 我不喜欢c++
    2. 我喜欢Python
    3. 这门课是“现代程序设计”而不是“现代C++设计”,所以我认为可以选择自己喜欢的语言
    1 flat=lambda L: sum(map(flat,L),[]) if isinstance(L,list) else [L]
    2 print ', '.join(flat([flat([j.split('.') for j in flat([i.split('/') for i in raw_input("Please enter the url:").split("://")])])]))
  • 相关阅读:
    “学霸系统”app——NABC
    Scrum Meeting NO.1
    团队成员角色
    团队作业 #2
    团队作业 #1
    Qt, 我回来了。。。
    boost: tcp client sample
    makefile 中定义宏位置需要注意一下
    libpcap报文解析: ipv4、ipv6 @ 2014.7.2
    编程网站收集
  • 原文地址:https://www.cnblogs.com/numbbbbb/p/3426443.html
Copyright © 2011-2022 走看看