#include <stdio.h>
int main(){
int i,j,n;
printf("Enter number: ");
scanf("%d", &n);
for(i=0;i<n;++i){
for(j=0;j<2*n;++j){
if(i%2==0 && j%2==1)
printf("%d", j % 10);
else
printf("-");
}
printf("\n");
}
return 0;
}
C Program - Another nested loop issue
-
12-06-2023 - |
문제
Just started to learn the nested loop logic in C Programming, and i don't know how to achieve in C Programming, the length and row should follow the input number, and use '-' to separate data
Enter number: 2
-1-3
----
Enter number: 7
-1-3-5-7-9-1-3
--------------
-1-3-5-7-9-1-3
--------------
-1-3-5-7-9-1-3
--------------
-1-3-5-7-9-1-3
Anyone knows how to achieve it? thanks for your help.
해결책
제휴하지 않습니다 StackOverflow