int main() { int n = 10, s = 0, i; int a[n]; srand(time(NULL)); cout<<"array:"<<endl; for (i=0; i<n; i++) { a[i]=rand() % 40-20; cout<<a[i]<<" "; } cout<<endl; i = 0; while ((i<n) && (a[i] != 0)) { s += a[i]; i++; } if (i == n) cout << "В массиве нет элементов = 0"; else cout << "s = " << s; system("pause"); return(0); }
37 div 10 = 3 58 div 10 = 5 125 div 10 = 12 234 div 10 = 23 873 div 100 = 8 3985 div 1000 = 3 37 mod 10 = 7 58 mod 10 = 8 125 mod 10 = 5 234 mod 10 = 4 873 mod 100 = 73 3985 mod 1000 = 985