c++ print number in some digits : I want to print number according to input N. 

As the range of N increases, I'll be so fucked up.

Is there another solution easier than this?

If someone helps me, i'll really appreciate it. Thanks!


         if (N == 3) {
			for (int a = 0; a < N; a++) {
				for (int b = 0; b < 3; b++) {
					printf("%03d ",y[a][b]);
				}
				cout << endl;
			}
		}
		else if (N == 4) {
			for (int a = 0; a < N; a++) {
				for (int b = 0; b < 3; b++) {
					printf("%04d ", y[a][b]);
				}
				cout << endl;
			}
		}
		else if (N == 5) {
			for (int a = 0; a < N; a++) {
				for (int b = 0; b < 3; b++) {
					printf("%05d ", y[a][b]);
				}
				cout << endl;
			}
		}
		else if (N == 6) {
			for (int a = 0; a < N; a++) {
				for (int b = 0; b < 3; b++) {
					printf("%06d ", y[a][b]);
				}
				cout << endl;
			}
		}
		else {
			for (int a = 0; a < N; a++) {
				for (int b = 0; b < 3; b++) {
					printf("%07d ", y[a][b]);
				}
				cout << endl;
			}
		}