U E D R , A S I H C RSS

LCD Display/Celfin

No older revisions available

No older revisions available



~cpp
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;

int n, h, i, j;
int length;
char s[8];

void display(int size, char *str)
{
	length = strlen(str);
	for(i=0; i<length; i++)
	{
		if(str[i]-48 == 1 || str[i]-48 == 4)
		{
			for(j=0; j<size+2; j++)
				cout <<" ";
		}
		else
		{
			cout << " ";
			for(j=0; j<size; j++)
				cout <<"-";
			cout << " ";
		}
		if(i!=length-1)
			cout <<" ";
	}
	cout << endl;

	for(h=0; h<size; h++)
	{
		for(i=0; i<length; i++)
		{
			if(str[i]-48 == 1 || str[i]-48 == 2 || str[i]-48 == 3 || str[i]-48 == 7)
				cout << " ";
			else
				cout << "|";
			for(j=0; j<size; j++)
				cout <<" ";
			if(str[i]-48 == 5 || str[i]-48 == 6)
				cout << " ";
			else
				cout << "|";
			if(i!=length-1)
				cout <<" ";
		}
		cout <<endl;
	}

	for(i=0; i<length; i++)
	{
		if(str[i]-48 == 1 || str[i]-48 == 7 || str[i]-48 == 0)
		{
			for(j=0; j<size+2; j++)
				cout <<" ";
		}
		else
		{
			cout << " ";
			for(j=0; j<size; j++)
				cout <<"-";
			cout << " ";
		}
		if(i!=length-1)
			cout <<" ";
	}
	cout << endl;

	for(h=0; h<size; h++)
	{
		for(i=0; i<length; i++)
		{
			if(str[i]-48 == 1 || str[i]-48 == 3 || str[i]-48 == 4 || str[i]-48 == 5 || str[i]-48 == 7 || str[i]-48 == 9)
				cout << " ";
			else
				cout << "|";
			for(j=0; j<size; j++)
				cout <<" ";
			if(str[i]-48 == 2)
				cout << " ";
			else
				cout << "|";
			if(i!=length-1)
				cout <<" ";
		}
		cout <<endl;
	}

	for(i=0; i<length; i++)
	{
		if(str[i]-48 == 1 || str[i]-48 == 4 || str[i]-48 == 7)
		{
			for(j=0; j<size+2; j++)
				cout <<" ";
		}
		else
		{
			cout << " ";
			for(j=0; j<size; j++)
				cout <<"-";
			cout << " ";
		}
		if(i!=length-1)
			cout <<" ";
	}
	cout << endl << endl;
}

int main()
{
	while(cin>>n>>s)
	{
		if(n==0 && s[0]=='0' && s[1]=='\0')
			break;
		display(n, s);
	}
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:36
Processing time 0.0271 sec