CC++ vs Python# include <iostream> using namespace std; int main () { int N,K,L=0,max,imax; cout<<"N="; cin>>N; cout<<"K="; cin>>K; int X[N],Y[K],Z[L]; for(int i=0; i<N; i++) { X[i]=rand()%N; } for(int i=0; i<N; i++) { if(X[i]>0) { Z[L]=X[i]; L++; } } for(int r=0; r<K; r++) { Y[r]=rand()%K; } for(int r=0; r<K; r++) { if(Y[r]>0) { Z[L]=Y[r]; L++; } } for(int j=0; j<L; j++) cout<<"Z["<<j<<"]="<<Z[j]<<endl; max=Z[0]; imax=0; for(int j=1; j<L; j++) { if(Z[j]>max) { max=Z[j]; imax=j; } } cout<<"max="<<max<<endl; cout<<"indeks="<<imax<<endl; return 0; } /stdin 5 605:35
CConta excluídaErrors: *** stack smashing detected ***: <unknown> terminated Abort signal from abort(3) (SIGABRT) Result: N=K=Z[0]=3 Z[1]=1 Z[2]=2 Z[3]=3 Z[4]=1 Z[5]=4 Z[6]=3 Z[7]=1 Z[8]=2 max=4 indeks=5 Tip: Mistake? Edit your message, I'll adjust my response.05:38