why not the answer of l is twenty four?and how to solve it!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dais dais
    New Member
    • Mar 2012
    • 1

    why not the answer of l is twenty four?and how to solve it!

    Code:
    #include<stdio.h>
    int main()
    {
    	int i,j,k,l=0;
    	printf("\n");
    	for(i=1;i!=5;++i)
    	{
    		for(j=1;j!=5;++j)
    		{
    			for(k=1;k!=5;++k)
    			{
    				if(i!=j&&i!=k&&j!=k)
    				{
    					printf("%d%d%d\t",i,j,k);
    					++l;
    					if(0==l%5)
    					{
    						printf("\n");
    						
    					}
    					
    				}
    			}
    		}
    	}
    	printf("%d\n");
    	return 0;
    }
    Last edited by Banfa; Mar 19 '12, 09:45 AM. Reason: Added [code]...c[/code] tags please use them in future
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You might try displaying l. I can't see you ever use it in the code

    BTW: I would avoid using variable names that look like numbers. l is a poor choice.

    Comment

    Working...