Solution :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<math.h> | |
int main() | |
{ | |
int n,i,even,sqr; | |
while(scanf("%d",&n)==1){ | |
for(i=2;i<=n;i++){ | |
if(i%2==0){ | |
sqr=pow(i,2); | |
printf("%d^2 = %d\n",i,sqr); | |
} | |
} | |
} | |
return 0; | |
} |
URI Problem : 1164
Solution :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int perfect_number(int n); | |
int main() | |
{ | |
int n,i,test; | |
while(scanf("%d",&test)==1){ | |
for(i=1;i<=test;i++){ | |
scanf("%d",&n); | |
if(n==perfect_number(n)){ | |
printf("%d eh perfeito\n",n); | |
} | |
else | |
printf("%d nao eh perfeito\n",n); | |
} | |
} | |
return 0; | |
} | |
int perfect_number(int n) | |
{ | |
int i=1,per_num=0; | |
while(i<n){ | |
if(n%i==0) | |
per_num=per_num+i; | |
i++; | |
} | |
if(per_num==n) | |
return n; | |
} |