#include <iostream>
using namespace std;
int main()
{
int tab[50] = { 0, 1 };
FILE* open,*wyjscie;
bool stan = false;
int ile;
int liczba;
int ost_el = 2;
int temp = -1;
open = fopen("text.txt", "r");
wyjscie = fopen("wyjscie.txt", "w+");
fscanf(open,"%d", &ile);
if (!(0 < ile && ile<= 10)) return 1;
do{
fscanf(open, "%d", &liczba);
if (!(0 < liczba && liczba <= 1000000000)) return 2;
if (temp < liczba) {
temp = liczba;
while(tab[ost_el-1]<liczba) {
tab[ost_el] = tab[ost_el - 2] + tab[ost_el - 1];
ost_el++;}
}
for (int i = 1; i < ost_el; i++)
{
if (liczba%tab[i] == 0)
{
for (int j = 1; j < ost_el; j++)
{
if (tab[j] == liczba / tab[i])
{
stan = true;
break;
}
}
}
if (stan) break;
}
if (stan) fprintf(wyjscie, "%s\n", "TAK");
else fprintf(wyjscie, "%s\n", "NIE");
stan = false;
} while (--ile);
fclose(open);
fclose(wyjscie);
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #include <iostream> using namespace std; int main() { int tab[50] = { 0, 1 }; FILE* open,*wyjscie; bool stan = false; int ile; int liczba; int ost_el = 2; int temp = -1; open = fopen("text.txt", "r"); wyjscie = fopen("wyjscie.txt", "w+"); fscanf(open,"%d", &ile); if (!(0 < ile && ile<= 10)) return 1; do{ fscanf(open, "%d", &liczba); if (!(0 < liczba && liczba <= 1000000000)) return 2; if (temp < liczba) { temp = liczba; while(tab[ost_el-1]<liczba) { tab[ost_el] = tab[ost_el - 2] + tab[ost_el - 1]; ost_el++;} } for (int i = 1; i < ost_el; i++) { if (liczba%tab[i] == 0) { for (int j = 1; j < ost_el; j++) { if (tab[j] == liczba / tab[i]) { stan = true; break; } } } if (stan) break; } if (stan) fprintf(wyjscie, "%s\n", "TAK"); else fprintf(wyjscie, "%s\n", "NIE"); stan = false; } while (--ile); fclose(open); fclose(wyjscie); return 0; } |
English