👤

Hei ! Cum as putea scrie sirul 1,2,1,2,3,2,1,2,3,4,3,2,1,2,3,4,5,4,3,2,1...... ? In C++

Răspuns :

int n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
    for(j=1;j<=i;j++)
        printf("%d,",j);
    for(j=n-1;j>=1;j++)
        printf("%d,",j);
}