va rog am nevoie de ajutor
Răspunsuri la întrebare
Răspuns:
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ifstream in("Date.in");
ofstream out("Date.out");
int n,v[100],i,s=0,p=1,o,r,maxim,aux,j,nr=0;
in>>n;
for(i=0;i<n;i++){ in>>v[i];
s+=v[i];
if(v[i]!=0) p*=v[i];}
maxim=v[0];
for(i=0;i<n;i++){
if(v[i]>10)
{ o=0;
r=v[i];
while(r!=0)
{
o=o*10+r%10;
r=r/10; }
if(o==v[i])
nr++;
}
}
for(i=1;i<n;i++) if(maxim<v[i]) maxim=v[i];
for(i=0;i<=n-1;i++)
for(j=i+1;j<n;j++)
if(v[j]<v[i]){aux=v[i];
v[i]=v[j];
v[j]=aux;}
out<<"Suma:"<<s<<endl;
out<<"Produsul:"<<p<<endl;
out<<"Numarul de palindrom:"<<nr<<endl;
if(maxim==v[i]) out<<maxim<<endl;
out<<"Vectorul sortat crescator este: "<<endl;
for(i=0;i<n;i++) out<<v[i]<<" ";
in.close();
out.close();
return 0;}
Explicație: