'commit'
This commit is contained in:
BIN
C++课程/第十九课活用数组下标/gmon.out
Normal file
BIN
C++课程/第十九课活用数组下标/gmon.out
Normal file
Binary file not shown.
34
C++课程/第十九课活用数组下标/p199.cpp
Normal file
34
C++课程/第十九课活用数组下标/p199.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int a[10]= {6,2,5,5,4,5,6,3,7,6},ans=0,temp=0,k;
|
||||
int num[2016];
|
||||
int n;
|
||||
cin>>n;
|
||||
num[0]=6;
|
||||
for(int i=1; i<=2000; i++) {
|
||||
k=i;
|
||||
while(k) {
|
||||
temp+=a[k%10];
|
||||
k/=10;
|
||||
}
|
||||
num[i]=temp;
|
||||
temp=0;
|
||||
}
|
||||
for(int i=0; i<=999; i++)
|
||||
for(int j=0; j<=999; j++) {
|
||||
if(num[i]+num[j]>=n)
|
||||
continue;
|
||||
else {
|
||||
if(num[i+j]+num[i]+num[j]+4==n) {
|
||||
ans++;
|
||||
cout<<i<<"["<<num[i]<<"]"<<"+"<<j<<"["<<num[j]<<"]"<<"="<<i+j<<"["<<num[i+j]<<"]"<<endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
cout<<ans;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
26
C++课程/第十九课活用数组下标/p200.cpp
Normal file
26
C++课程/第十九课活用数组下标/p200.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int MAXN=100001;
|
||||
int main() {
|
||||
int a[MAXN];
|
||||
int n,i,j,k;
|
||||
int maxsum;
|
||||
int temp;
|
||||
cin>>n;
|
||||
|
||||
for(i=1; i<=n; i++)
|
||||
cin>>a[i];
|
||||
maxsum=a[1];
|
||||
for(i=1; i<=n; i++)
|
||||
for(j=1; j<=n; j++) {
|
||||
temp=0;
|
||||
for(k=i; k<=j; k++)
|
||||
temp=temp+a[k];
|
||||
if(maxsum<temp) maxsum=temp;
|
||||
}
|
||||
cout<<maxsum;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
26
C++课程/第十九课活用数组下标/p201.cpp
Normal file
26
C++课程/第十九课活用数组下标/p201.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int MAXN=100001;
|
||||
int main() {
|
||||
int s[MAXN],a[MAXN];
|
||||
memset(s,0,sizeof(s));
|
||||
int n,i,j;
|
||||
int maxsum;
|
||||
int temp;
|
||||
cin>>n;
|
||||
for(i=1; i<=n; i++) {
|
||||
cin>>a[i];
|
||||
s[i]=a[i]+s[i-1];
|
||||
}
|
||||
maxsum=a[1];
|
||||
for(i=1; i<=n; i++)
|
||||
for(j=i; j<=n; j++) {
|
||||
temp=s[j]-s[i-1];
|
||||
if(maxsum<temp) maxsum=temp;
|
||||
}
|
||||
cout<<maxsum;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
37
C++课程/第十九课活用数组下标/p203.cpp
Normal file
37
C++课程/第十九课活用数组下标/p203.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int MAXN=1000001;
|
||||
|
||||
//https://blog.csdn.net/weixin_40295575/article/details/79627575
|
||||
//program received signal sigsegv<67><76><EFBFBD><EFBFBD>Ҫע<D2AA><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// ȷʵ<C8B7><CAB5>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鶨<EFBFBD><E9B6A8><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><DABA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
int a[MAXN];
|
||||
int main() {
|
||||
int n,i;
|
||||
int ans;
|
||||
int t;
|
||||
cin>>n;
|
||||
for(i=1; i<=n; i++)
|
||||
cin>>a[i];
|
||||
ans=a[1];
|
||||
t=ans;
|
||||
|
||||
for(i=2; i<=n; i++) {
|
||||
if(t>=0) {
|
||||
cout<<"t>=0 before "<<"i="<<i<<" "<<"t="<<t<<" "<<"ans="<<ans<<endl;
|
||||
t=t+a[i];
|
||||
cout<<"t>=0 end "<<"i="<<i<<" "<<"t="<<t<<" "<<"ans="<<ans<<endl;
|
||||
} else {
|
||||
cout<<"t<0 before "<<"i="<<i<<" "<<"t="<<t<<" "<<"ans="<<ans<<endl;
|
||||
t=a[i];
|
||||
cout<<"t<0 end "<<"i="<<i<<" "<<"t="<<t<<" "<<"ans="<<ans<<endl;
|
||||
}
|
||||
cout<<endl;
|
||||
if(t>ans) ans=t;
|
||||
}
|
||||
cout<<ans;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
3
C++课程/第十九课活用数组下标/最大子段和或最大连续段和_参考资料.txt
Normal file
3
C++课程/第十九课活用数组下标/最大子段和或最大连续段和_参考资料.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
https://blog.csdn.net/weixin_40170902/article/details/80585218
|
||||
|
||||
https://blog.csdn.net/liusu201601/article/details/89922088
|
||||
6
C++课程/第十九课活用数组下标/说明.txt
Normal file
6
C++课程/第十九课活用数组下标/说明.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
本课程时间较长,内容多,同时在此时安排了如何进行竞赛中要求的in 和out文件的样例练习。
|
||||
|
||||
https://www.cnblogs.com/littlehb/p/11781056.html
|
||||
|
||||
D:\少儿编程\教案与课程\C++专题课程\文件输入与输出
|
||||
区分二维输入和一维输入的方法,也练习一下输出文件。
|
||||
Reference in New Issue
Block a user