1) Varianta DlMuresan:
Citim un nume si data nasterii(pana la ^Z) si calculam numarul atasat numelui(nr de personalitate) si numarul atasat datei nasterii(nr destinului).
#include<iostream>2) Varianta B: Citim un nume si data nasterii(pana la ^Z) si calculam numarul atasat numelui(nr de personalitate) si numarul atasat datei nasterii(nr destinului).
using namespace std;
int main()
{int d=0,n=0,p,t,s=0;
char c;
while((c=cin.get()) != EOF)
{if(isdigit(c))
d=d+c-'0';
if(isalpha(c))
{
t=toupper(c);
switch(t%9)
{
case 2: n=n+1;break;
case 3: n=n+2;break;
case 4: n=n+3;break;
case 5: n=n+4;break;
case 6: n=n+5;break;
case 7: n=n+6;break;
case 8: n=n+7;break;
case 0: n=n+8;break;
case 1: n=n+9;break;
}}}
while(d>9){p=d;s=0;
while(p){s=s+p%10;p=p/10;}
d=s;}
while(n>9){p=n;s=0;
while(p){s=s+p%10;p=p/10;}
n=s;}
cout<<"nr de personalitate: "<<n<<endl;
cout<<"nr destinului: "<<d<<endl;
}
#include<iostream>
using namespace std;
int main()
{int P,D,s=0,n,p,S=0;
char nume, data;
while((nume=cin.get()) != EOF)
{ if(isalpha(nume))
{if((int)nume<74)s=s+(int)nume-64;
else if((int)nume<83) s=s+(int)nume-73;
else s=s+(int)nume-82;}
if(isdigit(nume))
S=S+(int)nume-48;
}
n=s;
while(n>9)
{
p=n;s=0;
while(p){s=s+p%10;p=p/10;}
n=s;
}
P=n;
cout<<"Numarul de personalitate: "<<P<<endl;
n=S;
while(n>9)
{
p=n;S=0;
while(p){S=S+p%10;p=p/10;}
n=S;
}
D=n;
cout<<"Numarul destinului: "<<D;
}