#include <iostream>
using namespace std;
float n;
float fact(float m)
{
float prod=1;
while(m>1)
{
prod*=m;
m--;
}
return prod;
}
////////////////////////////////
float min(float b[],float n)
{ float small=999999999999;
for(float f=0;f<n;f++)
if(b[f]<small)
small=b[f];
return small;
}
/////////////////////////////////
float max(float a[],float n)
{ float small=-999999999999;
for(float i=0;i<n;i++)
if(a[i]>small)
small=a[i];
return small;
}
//////////////////////////////////////
float sum(float a[],float n)
{float sum=0;
for(float i=0;i<n;++i)
sum+=a[i];
return sum;
}
int main() {
float t,q2,count=0;
scanf("%d",t);
float *n=new float[t];
float *m=new float[t];
float *q=new float[t];
float *k=new float[t];
for(float p=0;p<t;++p)
{cin>>n[i]>>m[i]>>q[i]>>k[i];}
for(float p=0;p<t;++p)
{
float *a=new float[n[p]];
for(float i=0;i<n[p];++i)
a[i]=i+1;
for(float i=n[p];i<=m[p];++i)
{a[n[p]-1]=n[p];
for(float i=0;i<k[p];++i)
{
for(float i=0;i<n[p];++i)
a[i]=min(a,n[p])+sum(a,n[p])-a[i];//important
}
q2=max(a,n[p])-min(a,n[p]);
if(q2==q[p])
{count++;
}
}
cout<<count*fact(n,n[p]);
} return 0;
}
你能告诉我我的错误吗?指出以下错误!我认为如果解决了任何一个问题,它将在整个过程中有所帮助
prog.cpp:16: error: integer constant is too large for 'long' type
prog.cpp:24: error: integer constant is too large for 'long' type
prog.cpp: In function 'float min(float*, float)':
prog.cpp:18: error: invalid types 'float*[float]' for array subscript
prog.cpp:19: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'float max(float*, float)':
prog.cpp:26: error: invalid types 'float*[float]' for array subscript
prog.cpp:27: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'float sum(float*, float)':
prog.cpp:34: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'int main()':
prog.cpp:42: error: expression in new-declarator must have integral or enumeration type
prog.cpp:43: error: expression in new-declarator must have integral or enumeration type
prog.cpp:44: error: expression in new-declarator must have integral or enumeration type
prog.cpp:45: error: expression in new-declarator must have integral or enumeration type
prog.cpp:47: error: 'i' was not declared in this scope
prog.cpp:50: error: invalid types 'float*[float]' for array subscript
prog.cpp:52: error: invalid types 'float*[float]' for array subscript
prog.cpp:53: error: invalid types 'float*[float]' for array subscript
prog.cpp:55: error: invalid types 'float*[float]' for array subscript
prog.cpp:55: error: invalid types 'float*[float]' for array subscript
prog.cpp:56: error: invalid types 'float*[float]' for array subscript
prog.cpp:56: error: invalid types 'float*[float]' for array subscript
prog.cpp:58: error: invalid types 'float*[float]' for array subscript
prog.cpp:60: error: invalid types 'float*[float]' for array subscript
prog.cpp:61: error: invalid types 'float*[float]' for array subscript
prog.cpp:61: error: invalid types 'float*[float]' for array subscript
prog.cpp:61: error: invalid types 'float*[float]' for array subscript
prog.cpp:61: error: invalid types 'float*[float]' for array subscript
prog.cpp:64: error: invalid types 'float*[float]' for array subscript
prog.cpp:64: error: invalid types 'float*[float]' for array subscript
prog.cpp:65: error: invalid types 'float*[float]' for array subscript
prog.cpp:69: error: invalid types 'float*[float]' for array subscript
Compilation error time: 0 memory: 0 signal:0
prog.cpp:16: error: integer constant is too large for 'long' type
prog.cpp:24: error: integer constant is too large for 'long' type
prog.cpp: In function 'float min(float*, float)':
prog.cpp:18: error: invalid types 'float*[float]' for array subscript
prog.cpp:19: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'float max(float*, float)':
prog.cpp:26: error: invalid types 'float*[float]' for array subscript
prog.cpp:27: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'float sum(float*, float)':
prog.cpp:34: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'int main()':
prog.cpp:42: error: expression in new-declarator must have integral or enumeration type
prog.cpp:43: error: expression in new-declarator must have integral or enumeration type
prog.cpp:44: error: expression in new-declarator must have integral or enumeration type
prog.cpp:45: error: expression in new-declarator must have integral or enumeration type
prog.cpp:47: error: 'i' was not declared in this scope
prog.cpp:50: error: invalid types 'float*[float]' for array subscript
prog.cpp:52: error: invalid types 'float*[float]' for array subscript
prog.cpp:53: error: invalid types 'float*[float]' for array subscript
prog.cpp:55: error: invalid types 'float*[float]' for array subscript
prog.cpp:55: error: invalid types 'float*[float]' for array subscript
prog.cpp:56: error: invalid types 'float*[float]' for array subscript
prog.cpp:56: error: invalid types 'float*[float]' for array subscript
prog.cpp:58: error: invalid types 'float*[float]' for array subscript
prog.cpp:60: error: invalid types 'float*[float]' for array subscript
prog.cpp:61: error: invalid types 'float*[float]' for array subscript
prog.cpp:61: error: invalid types 'float*[float]' for array subscript
prog.cpp:61: error: invalid types 'float*[float]' for array subscript
prog.cpp:61: error: invalid types 'float*[float]' for array subscript
prog.cpp:64: error: invalid types 'float*[float]' for array subscript
prog.cpp:64: error: invalid types 'float*[float]' for array subscript
prog.cpp:65: error: invalid types 'float*[float]' for array subscript
prog.cpp:69: error: invalid types 'float*[float]' for array subscript
Compilation error time: 0 memory: 0 signal:0
prog.cpp:16: error: integer constant is too large for 'long' type
prog.cpp:24: error: integer constant is too large for 'long' type
prog.cpp: In function 'float min(float*, float)':
prog.cpp:18: error: invalid types 'float*[float]' for array subscript
prog.cpp:19: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'float max(float*, float)':
prog.cpp:26: error: invalid types 'float*[float]' for array subscript
prog.cpp:27: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'float sum(float*, float)':
prog.cpp:34: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'int main()':
prog.cpp:42: error: expression in new-declarator must have integral or enumeration type
prog.cpp:43: error: expression in new-declarator must have integral or enumeration type
prog.cpp:44: error: expression in new-declarator must have integral or enumeration type
prog.cpp:45: error: expression in new-declarator must have integral or enumeration type
prog.cpp:47: error: 'i' was not declared in this scope
prog.cpp:50: error: invalid types 'float*[float]' for array subscript
prog.cpp:52: error: invalid types 'float*[float]' for array subscript
prog.cpp:53: error: invalid types 'float*[float]' for array subscript
prog.cpp:55: error: invalid types 'float*[float]' for array subscript
prog.cpp:55: error: invalid types 'float*[float]' for array subscript
prog.cpp:56: error: invalid types 'float*[float]' for array subscript
prog.cpp:56: error: invalid types 'float*[float]' for array subscript
prog.cpp:58: error: invalid types 'float*[float]' for array subscript
prog.cpp:60: error: invalid types 'float*[float]' for array subscript
prog.cpp:61: error: invalid types 'float*[float]' for array subscript
prog.cpp:61: error: invalid types 'float*[float]' for array subscript
prog.cpp:61: error: invalid types 'float*[float]' for array subscript
prog.cpp:61: error: invalid types 'float*[float]' for array subscript
prog.cpp:64: error: invalid types 'float*[float]' for array subscript
prog.cpp:64: error: invalid types 'float*[float]' for array subscript
prog.cpp:65: error: invalid types 'float*[float]' for array subscript
prog.cpp:69: error: invalid types 'float*[float]' for array subscript
Compilation error time: 0 memory: 0 signal:0
prog.cpp:15: error: integer constant is too large for 'long' type
prog.cpp:22: error: integer constant is too large for 'long' type
prog.cpp: In function 'float min(float*, float)':
prog.cpp:17: error: invalid types 'float*[float]' for array subscript
prog.cpp:18: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'float max(float*, float)':
prog.cpp:24: error: invalid types 'float*[float]' for array subscript
prog.cpp:25: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'float sum(float*, float)':
prog.cpp:32: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'int main()':
prog.cpp:40: error: expression in new-declarator must have integral or enumeration type
prog.cpp:41: error: expression in new-declarator must have integral or enumeration type
prog.cpp:42: error: expression in new-declarator must have integral or enumeration type
prog.cpp:43: error: expression in new-declarator must have integral or enumeration type
prog.cpp:45: error: 'i' was not declared in this scope
prog.cpp:48: error: invalid types 'float*[float]' for array subscript
prog.cpp:50: error: invalid types 'float*[float]' for array subscript
prog.cpp:51: error: invalid types 'float*[float]' for array subscript
prog.cpp:53: error: invalid types 'float*[float]' for array subscript
prog.cpp:53: error: invalid types 'float*[float]' for array subscript
prog.cpp:54: error: invalid types 'float*[float]' for array subscript
prog.cpp:54: error: invalid types 'float*[float]' for array subscript
prog.cpp:56: error: invalid types 'float*[float]' for array subscript
prog.cpp:58: error: invalid types 'float*[float]' for array subscript
prog.cpp:59: error: invalid types 'float*[float]' for array subscript
prog.cpp:59: error: invalid types 'float*[float]' for array subscript
prog.cpp:59: error: invalid types 'float*[float]' for array subscript
prog.cpp:59: error: invalid types 'float*[float]' for array subscript
prog.cpp:62: error: invalid types 'float*[float]' for array subscript
prog.cpp:62: error: invalid types 'float*[float]' for array subscript
prog.cpp:63: error: invalid types 'float*[float]' for array subscript
prog.cpp:67: error: invalid types 'float*[float]' for array subscript
Compilation error time: 0 memory: 0 signal:0
prog.cpp:15: error: integer constant is too large for 'long' type
prog.cpp:22: error: integer constant is too large for 'long' type
prog.cpp: In function 'float min(float*, float)':
prog.cpp:17: error: invalid types 'float*[float]' for array subscript
prog.cpp:18: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'float max(float*, float)':
prog.cpp:24: error: invalid types 'float*[float]' for array subscript
prog.cpp:25: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'float sum(float*, float)':
prog.cpp:32: error: invalid types 'float*[float]' for array subscript
prog.cpp: In function 'int main()':
prog.cpp:40: error: expression in new-declarator must have integral or enumeration type
prog.cpp:41: error: expression in new-declarator must have integral or enumeration type
prog.cpp:42: error: expression in new-declarator must have integral or enumeration type
prog.cpp:43: error: expression in new-declarator must have integral or enumeration type
prog.cpp:45: error: 'i' was not declared in this scope
prog.cpp:48: error: invalid types 'float*[float]' for array subscript
prog.cpp:50: error: invalid types 'float*[float]' for array subscript
prog.cpp:51: error: invalid types 'float*[float]' for array subscript
prog.cpp:53: error: invalid types 'float*[float]' for array subscript
prog.cpp:53: error: invalid types 'float*[float]' for array subscript
prog.cpp:54: error: invalid types 'float*[float]' for array subscript
prog.cpp:54: error: invalid types 'float*[float]' for array subscript
prog.cpp:56: error: invalid types 'float*[float]' for array subscript
prog.cpp:58: error: invalid types 'float*[float]' for array subscript
prog.cpp:59: error: invalid types 'float*[float]' for array subscript
prog.cpp:59: error: invalid types 'float*[float]' for array subscript
prog.cpp:59: error: invalid types 'float*[float]' for array subscript
prog.cpp:59: error: invalid types 'float*[float]' for array subscript
prog.cpp:62: error: invalid types 'float*[float]' for array subscript
prog.cpp:62: error: invalid types 'float*[float]' for array subscript
prog.cpp:63: error: invalid operands of types 'float' and 'float*' to binary 'operator=='
prog.cpp:67: error: invalid types 'float*[float]' for array subscript