Jump to content

Numere Naturale De 4 Cifre Care Sunt Egale Cu Patratul Cifrelor Lor


ldd.man25

Recommended Posts

Mda, am revenit cu o problema noua :D

 

4. Să se afiseze toate numerele naturale de maxim patru cifre care are proprietatea că sunt
egale cu pătratul cifrelor lor.
(exp : n=81, s=8+1=9 si 81=9*9)     

#include <iostream>
using namespace std;
int main(){
int c,i=0,s=0,x;

while(i<=9999){
    i++; s=0;
    while(i!=0){c=i%10; s=s+c; i=i10;}
    x=s*s;
    if(x==i){cout<<i<<' ';}
    }
return 0;}

buba e ca imi da eroare la linia 8, expected ";" before numeric constant.

M-am uitat de zece ori pana acuma si nu am gasit sa lipseasca nici un ';'. 

Cere sa se afiseze toate numerele de 4 cifre, care su patratul sumei cifrelor egale cu ele, cred ca e destul de corect, pareri?

Link to comment
Share on other sites

Mda, ai dreptate :)), era cam incurcat programul oricum, multumesc pt raspuns! (Eram cam obosit si acuma am vazut ca am creat un topic nou, asta poate sa fie inchis) 

 

edit: defapt nu eram atat de obosit, topicul a fost creat de administrator, am observat de abea acum. Oricum, nu mai am treaba aici, am inteles cum se face.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.