11.13的C++##不想寫結構,更不愛指針

//2019.11.13 卑微的Loving-Q瞎寫的程序 報錯請更改VS中的SDL檢查
// 我要去嗨了,在線卑微

1
#include<iostream> 2 #include<stdlib.h> 3 #include<math.h> 4 #include<cmath> 5 #include<cstdlib> 6 #include<stdio.h> 7 #include<string.h> 8 using namespace std; 9 //不想寫結構,更不愛指針 10 11 //struct book { 12 // char name[40]; 13 // char place[35]; 14 // float price; 15 //}; 16 // 17 // 18 // 19 //int main() 20 //{ 21 // struct book library= 22 // { 23 // 24 // "fsdfsdgdfg", 25 // "gdadagfkj", 26 // 999.99 27 // }; 28 // 29 // 30 // cout << library.price; 31 // return 0; 32 // 33 //} 34 // 35 //struct book //結構數組 36 //{ 37 // char name[40]; 38 // float price; 39 //}; 40 // 41 //int main() 42 //{ 43 // int i; 44 // int u; 45 // struct book wunyanan[3]; 46 // printf("先輸入字符串,在輸入浮點型的數據,用Enter隔開\n"); 47 // for (i = 0; i < 3; i++) 48 // { 49 // scanf("%s", &wunyanan[i].name); 50 // scanf("%f", &wunyanan[i].price); 51 // } 52 // for (u = 0; u < 3; u++) 53 // { 54 // cout << wunyanan[u].name << endl << wunyanan[u].price; 55 // } 56 // system("pause"); 57 // return 1; 58 //} 59 // ***********************************上面是結構體,下面是結構體的嵌套 60 struct a 61 { 62 int b; 63 float c; 64 }; 65 struct d 66 { 67 struct a first; 68 int e; 69 int f; 70 }; 71 72 int main() 73 { 74 int x; 75 struct d second = 76 { 77 { 234,44.23},55,6666 78 79 }; 80 81 for (x = 0; x < 5; x++) 82 { 83 cout << second.first.b<<endl; 84 } 85 return 0; 86 87 }
相關文章
相關標籤/搜索