This commit is contained in:
Light-City
2020-04-06 00:57:02 +08:00
parent f97c156cc4
commit a4d828bb4c
120 changed files with 4413 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
int i,j,k,f;
for (i=1;i<=4;i++){
for (j=1;j<=30;j++)
cout<<" ";
for (k=1;k<=8-2*i;k++)
cout<<" ";
for (f=1;f<=2*i;f++)
cout<<'*';
cout<<endl;
}
for(i=1;i<=3;i++){
for (j=1;j<=30;j++)
cout<<" ";
for (f=1;f<=7-2*i;f++)
cout<<'*';
cout<<endl;
}
system("pause");
return 0;
}

View File

@@ -0,0 +1,20 @@
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
int year;
bool isLeapYear;
cout<<"Enter the year: ";
cin>>year;
isLeapYear = (((year%4==0)&&(year%100!=0))||(year%400==0));
if(isLeapYear)
{
cout<<year<<" is a leap year"<<endl;
}
else
{
cout<<year<<" is not a leap year"<<endl;
}
system("pause");
return 0;
}

View File

@@ -0,0 +1,16 @@
#include<iostream>
//另一种注释方法
#if 0
asd
#endif
//打开注释
//条件编译指令
#if 1
asData
#endif

View File

@@ -0,0 +1,18 @@
#include<iostream>
using namespace std;
//相同的内存地址
union myun
{
struct { int x; int y; int z; }u;
int k;
}a;
int main()
{
a.u.x =4;
a.u.y =5;
a.u.z =6;
a.k = 0; //覆盖掉第一个int空间值
printf("%d %d %d %d\n",a.u.x,a.u.y,a.u.z,a.k);
system("pause");
return 0;
}