|
|
вернуться в форум0.001s 227 КБ var s1,s:string; i,k,x,code:integer; begin read(s); i:=2; s1:=s[1]+s[2]; repeat begin val(s1,k,code); x:=k mod 7; str(x,s1); inc(i); s1:=s1+s[i]; end; until i>=length(s); if s1<>'' then begin val(s1,k,code); x:=k mod 7; end; write(x); end. very simple Re: 0.001s 227 КБ Послано Alibek 4 мар 2008 19:22 slish, hare vipendrivats9 Re: 0.001s 227 КБ #include <stdio.h> #include <string.h> const int d[6] = {1,3,2,6,4,5}; int main() { char s[50]; gets(s); int sum = 0, n = strlen(s); for (int i = n - 1; i >= 0; --i) sum += ( s[i] - '0' ) * d[(n-1-i)%6]; printf("%d", sum%7); } Edited by author 02.12.2009 22:02 |
|
|