-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.txt
79 lines (63 loc) · 1.03 KB
/
default.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
第一题
#include<iostream>
#include<fstream>
using namespace std;
int main ()
{
int a[100];
int sum=0;
ifstream f("F:\\1.txt");
for(int c=0;f>>a[c],c<100;c++)
sum+=a[c];
cout<<sum;
}
第二题
#include<iostream>
#include<fstream>
using namespace std;
void Arraysum (int n)
{
int *a;
a=new int[n];
int sum=0;
ifstream f("F:\\1.txt");
for(int c=0;f>>a[c],c<n;c++)
sum+=a[c];
cout<<sum;
delete []a;
}
int main (void)
{
int n=0;
cout<<"输入数组长度";
cin>>n;
Arraysum(n);
}
第三题
#include<iostream>
#include<fstream>
using namespace std;
void Arraysum (int n,int e,int d)
{
int *a;
a=new int[n];
int sum=0;
ifstream f("F:\\1.txt");
for(int c=0;f>>a[c],c<n;c++)
if(a[c]>=e||d>=a[c])
sum+=a[c];
cout<<sum;
delete []a;
}
int main (void)
{
double e,d;
cout<<"输入指定范围的最小值";
cin>>e;
cout<<"输入指定范围的最大值";
cin>>d;
int n=0;
cout<<"输入数组长度";
cin>>n;
Arraysum(n,e,d);
}