随笔分类 -  C++ primer plus

摘要:第一题 1 #include 2 #include 3 using namespace std; 4 int main() 5 { 6 char arr[80]; 7 char ch; 8 cin.getline(arr,80); 9 int i=0;10 c... 阅读全文
posted @ 2014-12-07 22:04 陶修瑕 阅读(201) 评论(0) 推荐(0)
摘要:1 #include 2 using namespace std; 3 int main() 4 { 5 char ch; 6 int ct1,ct2; 7 ct1=ct2=0; 8 while((ch=cin.get())!='$') 9 {10 ... 阅读全文
posted @ 2014-12-07 20:55 陶修瑕 阅读(149) 评论(0) 推荐(0)
摘要:1 #include 2 using namespace std; 3 int main() 4 { 5 char ch; 6 int spaces=0,total=0; 7 cin.get(ch); 8 while(ch !='.')//注意使用单引号。 9 ... 阅读全文
posted @ 2014-12-06 21:46 陶修瑕 阅读(196) 评论(0) 推荐(0)
摘要:第一题 1 #include 2 using namespace std; 3 int main() 4 { 5 int a,b,sum=0; 6 cin>>a>>b; 7 for(int i=a;i 2 #include 3 using namespace std; 4 i... 阅读全文
posted @ 2014-12-06 19:50 陶修瑕 阅读(186) 评论(0) 推荐(0)
摘要:5.5循环和文本输入使用cin进行输入 1 #include 2 int main() 3 { 4 using namespace std; 5 char ch; 6 int count=0; 7 cout>ch; 9 while(ch!='#')10 ... 阅读全文
posted @ 2014-12-04 16:46 陶修瑕 阅读(173) 评论(0) 推荐(0)
摘要:5.1 for循环c++对for循环的调整。允许for(int i=0;i 2 #include 3 using namespace std; 4 int main() 5 { 6 string word; 7 cout>word;10 11 for(int i=0,j=wo... 阅读全文
posted @ 2014-12-04 15:37 陶修瑕 阅读(202) 评论(0) 推荐(0)
摘要:第一题 1 #include 2 #include 3 using namespace std; 4 int main() 5 { 6 char fristname[20]; 7 char lastname[20]; 8 char grade; 9 int age;1... 阅读全文
posted @ 2014-12-02 17:02 陶修瑕 阅读(172) 评论(0) 推荐(0)
摘要:1、1 char actors[30];2 short betsic[100];3 float chuck[13];4 long double dipsea[64];2、1 arrayactor;2 arraybestic;3 arraychuck;4 arraydipsea;3、int a[5]=... 阅读全文
posted @ 2014-12-02 14:07 陶修瑕 阅读(196) 评论(0) 推荐(0)
摘要:4.9类型组合 1 #include 2 struct years 3 { 4 int year; 5 }; 6 7 int main() 8 { 9 using namespace std;10 11 years s1,s2,s3;12 s1.year=1998;... 阅读全文
posted @ 2014-12-02 12:07 陶修瑕 阅读(127) 评论(0) 推荐(0)
摘要:如果给cout提供一个字符的地址,则他将从该字符开始打印,直到遇到空字符为止。 1 #include 2 #include 3 int main() 4 { 5 using namespace std; 6 char animal[20]="bear"; 7 const ch... 阅读全文
posted @ 2014-12-02 11:04 陶修瑕 阅读(276) 评论(0) 推荐(0)
摘要:4.7指针指针的危险:c++创建指针时,计算机会分配存储地址的内存,但是不会分配存储指针所指向的数据的内存。如:long *fellow;*fellow=233233;//危险,fellow指针所指向的位置是不知道的,一定要在对指针应用解除引用运算符(*)之前,将指针初始化为一个确定的、适当的地址。... 阅读全文
posted @ 2014-12-01 17:38 陶修瑕 阅读(209) 评论(0) 推荐(0)