0

1 13 135 1357 ....... ...... ......... n lines

22nd Sep 2016, 9:41 AM
Mayan Pahwa
Mayan Pahwa - avatar
2 ответов
+ 1
//example n = 17 void odd(int n) { int oddNr = 1; for(int c = 1 ; c <= n ; ++c) { cout<<oddNr; oddNr += 2; } cout<<endl; } int main() { for(int x = 1 ; x <= 17; x++) { odd(x); } return 0; }
22nd Sep 2016, 12:33 PM
Andres Mar
+ 1
Ah, you wanted a nested loop in that case, for n = 10 lines: int main() { for(int i = 1 ; i <= 10 ; i++) { int odd = 1; for(int j = 1 ; j <= i; j++) { cout<<odd; odd += 2; } cout<<endl; } return 0; }
22nd Sep 2016, 12:43 PM
Andres Mar