Waterloo Cup C language Basics Practice Letter Graphics __c Language

Source: Internet
Author: User
Topic Description

Using letters to make up some beautiful graphics, here's an example:

ABCDEFG

Babcdef

Cbabcde

Dcbabcd

Edcbabc

This is a 5 row 7 column of graphics, please find out the pattern of this graph, and output a n row m column of graphics. input

Enter a line that contains two integers n and m, representing the number of rows in the graph you want to output. output output n rows, each m character, for your graphics. Input Sample

5 7 Output Sample

ABCDEFG
Babcdef
Cbabcde
Dcbabcd
EDCBABC Data size and Convention

1 <= N, M <= 26. The main problem with the code is to find out the relationship between the subscript and the letter value.

#include <stdio.h>
#include <math.h>
int main ()
{
int m,n;
scanf ("%d%d", &n,&m);
int i,j;
for (i=0;i<n;i++)
{
for (j=0;j<m;j++)
{
printf ("%c", 65+abs (i-j));         
}
printf ("\ n");
return
0;
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.