Header Ads

Header ADS

Solution of URI 1146::Growing Sequences

Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problemyou will inform me by comment.



#include <stdio.h>

int main()
{
    int X,i;

    while(scanf("%d",&X) !=EOF) {
        if(X==0) {
            return 0;
        }
        for(i=1;i<=X;i++) {
                if(i==X) {
                    printf("%d",i);
                }
                else
            printf("%d ",i);
        }
        printf("\n");
    }
    return 0;
}

No comments

Theme images by konradlew. Powered by Blogger.