Skip to content

Instantly share code, notes, and snippets.

@Zoha131
Last active February 26, 2017 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zoha131/fe4627ab75f2d0f2bdd85a71fe7f8960 to your computer and use it in GitHub Desktop.
Save Zoha131/fe4627ab75f2d0f2bdd85a71fe7f8960 to your computer and use it in GitHub Desktop.
My code works fine with the sample inputs. But whenever I submit the code to code marshal, it gets unaccepted.
#include <stdlib.h>
#include <stdio.h>
int main()
{
int i, j, t, k,m,n;
scanf("%d", &t);
for(i=1; i<=t; i++)
{
scanf("%d", &k);
for(j = 0; j< k; j++ )
{
for(m = k-1; m>j; m--)
{
printf(" ");
}
for(n=0; n<=j*2; n++)
{
printf("*");
}
printf(" \n");
}
printf("\n");
}
return 0;
}
#include <stdlib.h>
#include <stdio.h>
int main()
{
int i, j, n, m;
unsigned short int t,k;
scanf("%hu", &t);
for(i=1; i<=t; i++)
{
scanf("%hu", &k);
for(j = 0; j< k; j++ )
{
for(m = k-1; m>j; m--)
{
printf(" ");
}
for(n=0; n<=j*2; n++)
{
printf("*");
}
printf("\n");
}
for(j = k-2; j>=0; j-- )
{
for(m = k-1; m>j; m--)
{
printf(" ");
}
for(n=0; n<=j*2; n++)
{
printf("*");
}
printf("\n");
}
printf("\n");
}
return 0;
}
#include <stdlib.h>
#include <stdio.h>
int main()
{
int i,j,k,l,N,t, temp;
scanf("%d", &t);
for(l=0; l<t;l++)
{
scanf("%d",&N);
int n_array[N];
for(i=0; i<N; i++)
{
scanf("%d", &n_array[i]);
}
j = i-1;
i=0;
while(i<j)
{
temp = n_array[i];
n_array[i] = n_array[j];
n_array[j] = temp;
j--;
i++;
}
printf("%d", n_array[0]);
for(k = 1; k<N; k++)
{
printf(" %d", n_array[k]);
}
printf("\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment