Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,500 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,366 people online right now. Registration is fast and FREE... Join Now!




Display the number In 7*7 Mtrices form

 
Reply to this topicStart new topic

Display the number In 7*7 Mtrices form

prachi
1 Mar, 2007 - 05:10 PM
Post #1

New D.I.C Head
*

Joined: 27 Feb, 2007
Posts: 2


My Contributions
CODE
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
main()
{
        int i,n,x,c,y;
         int length=100;
         int arr [7][7];
        int a[length];
        printf("enter the size:");
        scanf("%d",&n);
        printf("enter the no:");
        scanf("%d",&x);
        y=x;
        for(i=n-1;i>0;i--)
        {
                c=(int)y/pow(10,i-1);
                 a[i]=c;
                printf("%d",c);
                y=y-c*pow(10,i-1);
        }
switch©
{
        case 0:arr[][7]={1,1,1,1,1,1,1,
                         1,0,0,0,0,0,1,
                         1,0,0,0,0,0,1,
                         1,0,0,0,0,0,1,
                         1,0,0,0,0,0,1,
                         1,0,0,0,0,0,1,
                         1,1,1,1,1,1,1};
               break;
        case 1:arr[][7]={0,0,0,1,0,0,0,
                         0,0,1,1,0,0,0,
                         0,1,0,1,0,0,0,
                         0,0,0,1,0,0,0,
                         0,0,0,1,0,0,0,
                         0,0,0,1,0,0,0,
                         1,1,1,1,1,1,1};
               break;
        case 2:arr[][7]={1,1,1,1,1,1,1,
                         0,0,0,0,0,0,1,
                         0,0,0,0,0,0,1,
                         1,1,1,1,1,1,1,
                         1,0,0,0,0,0,0,
                         1,0,0,0,0,0,0};

        case 3:arr[][7]={1,1,1,1,1,1,1,
                         0,0,0,0,0,0,1,
                         0,0,0,0,0,0,1,
                         1,1,1,1,1,1,1,
                         0,0,0,0,0,0,1,
                         0,0,0,0,0,0,1,
                         1,1,1,1,1,1,1};
               break;
         case 4:arr[][7]={1,0,0,0,0,0,1,
                          1,0,0,0,0,0,1,
                          1,0,0,0,0,0,1,
                          1,1,1,1,1,1,1,
                          0,0,0,0,0,0,1,
                          0,0,0,0,0,0,1,
                          0,0,0,0,0,0,1};
                break;

         case 5:arr[][7]={1,1,1,1,1,1,1,
                          1,0,0,0,0,0,0,
                          1,0,0,0,0,0,0,
                          1,1,1,1,1,1,1,
                          0,0,0,0,0,0,1,
                          0,0,0,0,0,0,1,
                          1,1,1,1,1,1,1};
                break;
         case 6:arr[][7]={1,1,1,1,1,1,1,
                          1,0,0,0,0,0,0,
                          1,0,0,0,0,0,0,
                          1,1,1,1,1,1,1,
                          1,0,0,0,0,0,1,
                          1,0,0,0,0,0,1,
                          1,1,1,1,1,1,1};
                break;
         case 7:arr[][7]={1,1,1,1,1,1,1,
                          0,0,0,0,0,0,1,
                          0,0,0,0,0,0,1,
                          0,0,0,0,0,0,1,
                          0,0,0,0,0,0,1,
                          0,0,0,0,0,0,1,
                          0,0,0,0,0,0,1};
                break;
         case 8:arr[][7]={1,1,1,1,1,1,1,
                          1,0,0,0,0,0,1,
                          1,0,0,0,0,0,1,
                          1,1,1,1,1,1,1,

this manner i have created 9 nos but i m not sure if my ;logic is prefect i have to call a function biglen(170) then it will represent my no in big 7*7 matrices.
Any help will be appreciated.
Thanks alot .

EDIT - CODE Tags Added -b2c-
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Display The Number In 7*7 Mtrices Form
1 Mar, 2007 - 07:25 PM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,867



Thanked: 53 times
Dream Kudos: 550
My Contributions
I think you are asking how to print out the image of a number using a 7x7 matrix. So, for example, to show the number 5 you might display

1111111
1000000
1000000
1111111
0000001
0000001
1111111

In which case there is a good deal of your program that I don't understand:

You can represent the number in a 7x7 array as you have (for the most part) in the above program. I myself would probably store the number is a set of const char Char0={}; arrays, or store all of the numbers in a single buffer const char CharBuffer[490]={}; and then make a function to print the data.

IF sounds like what you are tring to do let me know and I can be of more assistance.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 06:29PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month