|
|
back to boardqayerida xato gde awipka...? var f,i:longint; k:1..20; n:1..10; s:string; begin readln(n); read(s); f:=1; k:=length(s); for i:=0 to (n div k)-1 do begin f:=f*(n-i*k); end; writeln(f); end. Re: qayerida xato gde awipka...? Posted by Sunnat 6 Dec 2011 21:05 Nargiza sizning xatoyingiz sonni va faktarialni ajratib olishda, va bundan tashqari hisoblash tsiklida n dan 1 ga tomon qadam k shaklida oling Re: qayerida xato gde awipka...? ya'ni.....qanday Re: qayerida xato gde awipka...? hisoblash tsiklida n dan 1 ga tomon qadam k shaklida olinishi kerak xatolik quyidagicha Posted by Sunnat 7 Dec 2011 16:12 sizda menimcha kiritish jarayonida raqam(n) va undov(!) orasida probel(_) qo'ymasdan yozganda xato ishlashi mumkin. shunda undovlarni ham raqam sifatida o'qib s ni uzunligi 0 ga teng bo'lib qoladi. shuning uchun n/l(n bo'lingan s ning uzunligi) n/0 bo'lib qolyapti shunda sizga Crash (integer division by zero) ashibka beryapti Re: qayerida xato gde awipka...? Re: qayerida xato gde awipka...? Posted by Djet 19 Jul 2013 01:41 #include <iostream> using namespace std; int main() { int n,t,s; cin>>n; char k[20]; gets(k); s=n; t=n%(strlen(k)-1); if(t!=0) while(n>t) { n=n-(strlen(k)-1); s*=n; } else while(n>(strlen(k)-1)) { n=n-(strlen(k)-1); s*=n; } cout<<s<<endl;
return 0; } |
|
|