|
|
back to boardwhat's wrong with that code :( #include <cstdlib> #include <iostream> //----------Funkcje---------------------------- long long nwd(long long a, long long b) { if (b>=1) nwd(b, a%b); if (b=0) return a; } using namespace std; //---------------Program------------------------------------ int main(int argc, char *argv[]) { int n; long long tab[1002]={0}; //printf("Dla ilu liczb chcesz policzyc NWD?: \n"); scanf("%d", &n); //printf("Podaj liczby: \n"); for (int i=0;i<n;i++) scanf("%I64d", &tab[i]); long long wynik=tab[0]; for (int i=0;i<n-1;i++) { wynik=nwd(tab[i],tab[i+1]); tab[i+1]=wynik; }
//printf("NWD wynosi %I64d \n", wynik); printf("%I64d", wynik);
system("PAUSE"); return EXIT_SUCCESS; } Re: what's wrong with that code :( use __int64 instead long long |
|
|