[课程相关]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("://")])])]))

 

转载于:https://www.cnblogs.com/numbbbbb/p/3426443.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值