#2911 (pbinfo)
Cerința
Se dă un număr natural n. Să se afișeze fiecare cifră a numărului folosind simbolul @, ca în exemplu.
Date de intrare
Programul citește de la tastatură numărul n.
Date de ieșire
Programul va afișa pe ecran fiecare cifră a numărului citit scrisă. După fiecare cifră se va lăsa un rând gol.
Restricții și precizări
1≤n≤1010
Exemplu
Intrare
1234567890
Ieșire
@
@@
@
@
@@@@@
@@@@
@ @
@
@
@@@@
@@@@@
@
@@@@@
@
@@@@@
@ @
@ @
@@@@@
@
@
@@@@@
@
@@@@@
@
@@@@@
@@@@@
@
@@@@@
@ @
@@@@@
@@@@
@
@@@
@
@
@@@@@
@ @
@@@@@
@ @
@@@@@
@@@@@
@ @
@@@@@
@
@
@@@@@
@ @
@ @
@ @
@@@@@
Răspunsuri la întrebare
Răspuns:
Explicație:
#include <iostream>
#include <string.h>
using namespace std;
char k[50];
int main()
{
cin >> k;
for(int i=0; i<strlen(k); i++) {
if(k[i] == '0')
{
cout<<"@@@@@"<<endl;
cout<<"@"<<" "<<"@"<<endl;
cout<<"@"<<" "<<"@"<<endl;
cout<<"@"<<" "<<"@"<<endl;
cout<<"@@@@@"<<endl;
}
if(k[i]=='1') {
cout <<" "<<" ";
cout<<"@"<<endl;
cout <<" ";
cout<<"@@"<<endl;
cout <<" "<<" ";
cout<<"@"<<endl;
cout <<" "<<" ";
cout<<"@"<<endl;
cout<<"@@@@@"<<endl;
}
if(k[i]=='2')
{
cout<<"@@@@"<<endl;
cout <<"@" <<" "<<" "<<"@"<<endl;
cout <<" "<<"@"<<endl;
cout<<" "<<"@"<<endl;
cout<<"@@@@"<<endl;
}
if(k[i]=='3')
{
cout<<"@@@@@"<<endl;
cout<<" "<<"@"<<endl;
cout<<"@@@@@"<<endl;
cout<<" "<<"@"<<endl;
cout<<"@@@@@"<<endl;
}
if(k[i] == '4')
{
cout <<"@"<<" "<<"@"<<endl;
cout <<"@"<<" "<<"@"<<endl;
cout<<"@@@@@"<<endl;
cout <<" "<<"@"<<endl;
cout <<" "<<"@"<<endl;;
}
if(k[i] == '5')
{
cout<<"@@@@@"<<endl;
cout<<"@"<<" "<<endl;
cout<<"@@@@@"<<endl;
cout<<" "<<"@"<<endl;
cout<<"@@@@@"<<endl;
}
if(k[i] == '6')
{
cout<<"@@@@@"<<endl;
cout<<"@"<<" "<<endl;
cout<<"@@@@@"<<endl;
cout<<"@"<<" "<<"@"<<endl;
cout<<"@@@@@"<<endl;
}
if(k[i] == '7')
{
cout<<"@@@@"<<endl;
cout<<" "<<"@"<<endl;
cout<<" "<<"@@@"<<endl;
cout<<" "<<"@"<<endl;
cout<<" "<<"@"<<endl;
}
if(k[i] == '8')
{
cout<<"@@@@@"<<endl;
cout<<"@"<<" "<<"@"<<endl;
cout<<"@@@@@"<<endl;
cout<<"@"<<" "<<"@"<<endl;
cout<<"@@@@@"<<endl;
}
if(k[i] == '9')
{
cout<<"@@@@@"<<endl;
cout<<"@"<<" "<<"@"<<endl;
cout<<"@@@@@"<<endl;
cout<<" "<<"@"<<endl;
cout<<" "<<"@"<<endl;
}
}
return 0;
}