编程知识 cdmana.com

Excuse me, where is the wrong pointer

problem : Input 12 A positive integer , After removing a minimum and a maximum , Find the remainder 10 Sum of positive integers .

Expected input :

98 45 234 1 5 7 98 6 45 90 4 56

Expected output :

sum=454

```c++

```#include
using namespace std;
int main()
{
int a[12];
int *t,t=a;
int *q,q=a;
int p=a;
int i,sum=0;
for(i=0;i<12;i++)
{
cin>>
(p+i);
}
for(i=0;i<12;i++)
{
if(*t>a[i])
t=a[i];
}
for(i=0;i<12;i++)
{
if(*q<a[i])
q=a[i];
}
*t=0,*q=0;
for(i=0;i<12;i++)
{
sum+=a[i];
}
cout<<"sum="<<sum<<endl;
return 0;
}

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://cdmana.com/2022/134/202205072105105513.html

Scroll to Top