Istifadəçi |
2012-05-30 12:40 GMT |
|
|
|
İstifadəçi |
|
Mesaj Sayı : 144 |
Mövzu Sayı : |
Rep Ver : |
Rep Sayı : 5 |
Indi Saytda : |
Cinsiyyət : Oğlan |
|
Şəhər : Putnam, Connecticut |
Ölkə : |
Məslək : System & Algorithmic Programmer, Security Professional |
Yaş : 121 |
Mesaj : |
|
Bu mövzuda girilən ədədləri ve böyüklüyü analiz edərək CMD-dəki kimi rəqəminizi ekrana verən kodumu paylaşacağam. Lazım olar
Programlama Dili: C++
Compiler: gnuc++
Tövsiyyə olunan Editor: CodeBlocks vəya Dev-C++
Kod: #include <iostream>
#include <math.h>
using namespace std;
const char DIGITS[10][5][3] =
{{{' ','-',' '},
{'|',' ','|'},
{' ',' ',' '},
{'|',' ','|'},
{' ','-',' '}}, //0
{{' ',' ',' '},
{' ',' ','|'},
{' ',' ',' '},
{' ',' ','|'},
{' ',' ',' '}}, //1
{{' ','-',' '},
{' ',' ','|'},
{' ','-',' '},
{'|',' ',' '},
{' ','-',' '}}, //2
{{' ','-',' '},
{' ',' ','|'},
{' ','-',' '},
{' ',' ','|'},
{' ','-',' '}}, //3
{{' ',' ',' '},
{'|',' ','|'},
{' ','-',' '},
{' ',' ','|'},
{' ',' ',' '}}, //4
{{' ','-',' '},
{'|',' ',' '},
{' ','-',' '},
{' ',' ','|'},
{' ','-',' '}}, //5
{{' ','-',' '},
{'|',' ',' '},
{' ','-',' '},
{'|',' ','|'},
{' ','-',' '}},//6
{{' ','-',' '},
{' ',' ','|'},
{' ',' ',' '},
{' ',' ','|'},
{' ',' ',' '}},//7
{{' ','-',' '},
{'|',' ','|'},
{' ','-',' '},
{'|',' ','|'},
{' ','-',' '}}, //8
{{' ','-',' '},
{'|',' ','|'},
{' ','-',' '},
{' ',' ','|'},
{' ','-',' '}}};
int main()
{
int s, n;
int length;
while (cin >> s >> n) {
if (s == 0 && n == 0) {
break;
}
if (s == 0) continue;
if (n != 0)
length=(int)log10((float)n)+1;
else length=1;
int feld[length];
for (int i =length-1;i>=0;i--) {
feld[i]=n%10;
n/=10;
}
for (int i = 0;i<length;i++) {//first line
cout<<" ";
for (int z=0;z<s;z++)
cout<<DIGITS[feld[i]][0][1];
if (i!=length-1) cout<<" ";
else cout<<" ";
}
cout<<endl;
for (int z =0;z<s;z++){ //second line
for (int i = 0;i<length;i++) {
cout<<DIGITS[feld[i]][1][0];
for (int b=0;b<s;b++)
cout<<" ";
cout<<DIGITS[feld[i]][1][2];
if (i!=length-1) cout<<" ";
}
cout<<endl;
}
for (int i = 0;i<length;i++) {//first line
cout<<" ";
for (int z=0;z<s;z++)
cout<<DIGITS[feld[i]][2][1];
if (i!=length-1) cout<<" ";
else cout<<" ";
}
cout<<endl;
for (int z =0;z<s;z++){ //second line
for (int i = 0;i<length;i++) {
cout<<DIGITS[feld[i]][3][0];
for (int b=0;b<s;b++)
cout<<" ";
cout<<DIGITS[feld[i]][3][2];
if (i!=length-1) cout<<" ";
}
cout<<endl;
}
for (int i = 0;i<length;i++) {//first line
cout<<" ";
for (int z=0;z<s;z++)
cout<<DIGITS[feld[i]][4][1];
if (i!=length-1) cout<<" ";
else cout<<" ";
}
cout<<endl<<endl;
}
}
|
Anti-armenia.ORG |
|