Skip to content

Instantly share code, notes, and snippets.

@feynon
Last active October 31, 2018 12:47
Show Gist options
  • Save feynon/1cf39fe23fa648a3b294eb5f4af1924b to your computer and use it in GitHub Desktop.
Save feynon/1cf39fe23fa648a3b294eb5f4af1924b to your computer and use it in GitHub Desktop.
//https://www.spoj.com/problems/CPTTRN1/
/*
Input:
3
3 1
4 4
2 5
Output:
*
.
*
*.*.
.*.*
*.*.
.*.*
*.*.*
.*.*.
*/
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
int t, l, c, i, j;
scanf("%d",&t);
for(i=0;i<t;i++)
{
for(i=1; i<=l; i++)
{
for(j=1; j<=c; j++)
{
if((i+j)%2 == 0 )
{
printf("*");
}
else
{
printf(".");
}
}
}
printf("\n\n");
}
return 0;
}
//https://www.spoj.com/problems/CPTTRN1/
/*
Input:
3
3 1
4 4
2 5
Output:
*
.
*
*.*.
.*.*
*.*.
.*.*
*.*.*
.*.*.
*/
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
int t, l, c, i, j;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&l, &c);
for(i=0; i<=l; i++)
{
for(j=0; j<=c; j++)
{
if((i+j)%2 == 0 )
printf("*");
else
printf(".");
}
printf("\n");
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment