For example 1 3 5 7 9 11 17 19 you need to do
1 3 5 7 9
11 17 19
without the use of arrays, using an auxiliary variable, simple output numbers.
For example 1 3 5 7 9 11 17 19 you need to do
without the use of arrays, using an auxiliary variable, simple output numbers.
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
Well, since you need to divide prime numbers in dozens, then just add to the program you indicated in the comment:
int main(int argc, const char * argv[]) { int n = 100; cout << 2 << endl; for (int last = 2, j = 3; j < n; j+=2) { bool flag = true; if (j%2 == 0) continue; for (int a = 3; a*a <= j; a+=2) { if (j%a == 0) { flag = false; break; } } if (flag) { if (j/10 != last/10) cout << "\n"; cout << j << " "; last = j; } } } I hope everything is clear? When going through a dozen, we display a newline character ...
If the source numbers are in a sorted array, then
void print(int * nums, int cnt) { if (cnt == 0) return; int dec = nums[0] / 10; for (int i = 0; i < cnt; i++) { int cur_dec = nums[i] / 10; if (curdec != dec) { cout << endl; dec = cur_dec; } cout << num[i] << ' '; } } a , b , c , d ...? - Anton Shchyrov 4:05 pmSource: https://ru.stackoverflow.com/questions/579767/
All Articles