level 13
狗gou富贵
楼主
#include <iostream>
using namespace std;
int n;
int *p1;
int fun(){
static int a;
int b;
cout<<"a="<<a<<",";
cout<<"b="<<b<<endl;
}
void main(){
int *p2;
int m;
fun(){
int n(10),m(20);
cout<<"n="<<n<<endl<<"m="<<m<<endl;
}
cout<<"n="<<n<<endl<<"m="<<m<<endl;
if(p1)
cout<<"p1="<<p1<<endl;
if(p2)
cout<<"p2="<<p2<<endl;
}
#include <iostream.h>
double f(int a=10,int b=20,int c=5){
return a*b*c;
}
void main(){
cout<<f()<<endl<<f(20)<<endl<<f(10,10)<<endl<<f(10,10,10)<<endl;
}
#include <iostream>
#include <memory>
using namespace std;
struct node{
int data;
shared_ptr<node>next;
};
void main(){
int a[]={3,4,1,8,9,2,7};
shared_ptr<node>list(new node),p;
list->data=0;
for(auto v:a){
shared_ptr<node>q(new node)
q->data = v;
p->next = q;
p = p-> next;
}
p->next=null;
p=list->next;
int s=0;
while(p){
cout<<p->data<<"\n";
s+=p->data;
p=p->next;
}
cout<<"\ns="<<s<<endl;
}
2018年03月22日 13点03分
1
using namespace std;
int n;
int *p1;
int fun(){
static int a;
int b;
cout<<"a="<<a<<",";
cout<<"b="<<b<<endl;
}
void main(){
int *p2;
int m;
fun(){
int n(10),m(20);
cout<<"n="<<n<<endl<<"m="<<m<<endl;
}
cout<<"n="<<n<<endl<<"m="<<m<<endl;
if(p1)
cout<<"p1="<<p1<<endl;
if(p2)
cout<<"p2="<<p2<<endl;
}
#include <iostream.h>
double f(int a=10,int b=20,int c=5){
return a*b*c;
}
void main(){
cout<<f()<<endl<<f(20)<<endl<<f(10,10)<<endl<<f(10,10,10)<<endl;
}
#include <iostream>
#include <memory>
using namespace std;
struct node{
int data;
shared_ptr<node>next;
};
void main(){
int a[]={3,4,1,8,9,2,7};
shared_ptr<node>list(new node),p;
list->data=0;
for(auto v:a){
shared_ptr<node>q(new node)
q->data = v;
p->next = q;
p = p-> next;
}
p->next=null;
p=list->next;
int s=0;
while(p){
cout<<p->data<<"\n";
s+=p->data;
p=p->next;
}
cout<<"\ns="<<s<<endl;
}

