|
|
вернуться в форумWhy Crash? Послано NiF 27 окт 2012 18:37 #include <iostream> #include <string> #include <stdlib.h> using namespace std; int main() { string s; char ss[10]; short l, i; int ostatok = 0, mnojitel = 1; cin >> s, ss; while (i < s.length() / 8) { l = s.copy(ss, 8, i*8); ss[9] = '\0'; ostatok = (ostatok * 100000000 + atoi(ss)) % 7; i++; } for (l = 0; l < s.length() - i*8; l++) mnojitel *= 10; l = s.copy(ss, s.length() - i*8, i*8); ss[s.length() - i*8] = '\0'; ostatok = (ostatok * mnojitel + atoi(ss)) % 7; cout << ostatok << endl; return 0; } It's work on my PC and give true results for input data from "Test Cases" |
|
|