'commit'
This commit is contained in:
27
C++课程/第十七课一维数组/moni.cpp
Normal file
27
C++课程/第十七课一维数组/moni.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int n,k;
|
||||
int s=0,b=0;
|
||||
cin >> n >> k;
|
||||
while(1)
|
||||
{
|
||||
n--;
|
||||
s++;
|
||||
b++;
|
||||
if(b==k)
|
||||
{
|
||||
n++;
|
||||
b=0;
|
||||
}
|
||||
if(n==0 && b<k)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
cout<<s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
16
C++课程/第十七课一维数组/p184.cpp
Normal file
16
C++课程/第十七课一维数组/p184.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
const int MAXN=10000;
|
||||
int main() {
|
||||
int a[MAXN];
|
||||
int i,n;
|
||||
cin>>n;
|
||||
for(i=0; i<n; i++)
|
||||
cin>>a[i];
|
||||
for(i=n-1; i>=0; i--)
|
||||
cout<<a[i]<<" ";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
18
C++课程/第十七课一维数组/p186.cpp
Normal file
18
C++课程/第十七课一维数组/p186.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int a[20];
|
||||
int i;
|
||||
a[0]=0;
|
||||
a[1]=1;
|
||||
for(i=2; i<20; i++)
|
||||
a[i]=a[i-2]+a[i-1];
|
||||
|
||||
for(i=19; i>=0; i--)
|
||||
cout<<a[i]<<" ";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
18
C++课程/第十七课一维数组/p188.cpp
Normal file
18
C++课程/第十七课一维数组/p188.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int year,month,date,ans;
|
||||
int main() {
|
||||
int a[13]= {0,31,28,31,30,31,30,31,31,30,31,30,31};
|
||||
cin>>year>>month>>date;
|
||||
for(int i=1; i<month; i++)
|
||||
ans+=a[i];
|
||||
|
||||
ans+=date;
|
||||
if(year%4==0 and year%100!=0 or year%400==0)
|
||||
if(month>2) ans++;
|
||||
cout<<ans;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
21
C++课程/第十七课一维数组/p194.cpp
Normal file
21
C++课程/第十七课一维数组/p194.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int MAXN=10001;
|
||||
|
||||
int main() {
|
||||
int a[MAXN];
|
||||
int n,k;
|
||||
int i,j;
|
||||
memset(a,0,sizeof(a));
|
||||
cin>>n>>k;
|
||||
for(i=2; i<=k; i++)
|
||||
for(j=1; j<=n; j++)
|
||||
if(j%i==0) a[j]=!a[j];
|
||||
|
||||
for(i=1; i<=n; i++)
|
||||
if(!a[i])
|
||||
cout<<i<<" ";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
16
C++课程/第十七课一维数组/tmp_t_count.cpp
Normal file
16
C++课程/第十七课一维数组/tmp_t_count.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int n=0,ans=0;
|
||||
cin >>n;
|
||||
int tmp=n;
|
||||
while(tmp>=1) {
|
||||
if(tmp%10==2) ans++;
|
||||
tmp/=10;
|
||||
}
|
||||
cout<<ans;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
1
C++课程/第十七课一维数组/勇者斗恶龙.txt
Normal file
1
C++课程/第十七课一维数组/勇者斗恶龙.txt
Normal file
@@ -0,0 +1 @@
|
||||
https://blog.csdn.net/zenail501129/article/details/24090035
|
||||
Reference in New Issue
Block a user