Robert_Manea

cifra max si cifra min

Nov 18th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {int n,i,s,max1=0,min1=100,x,y,nmax,nmin;
  6. scanf("%d",&n);
  7. for(i=1;i<=n;i++){
  8. scanf("%d",&x);
  9. s=0;
  10. y=x;
  11. while(x!=0){
  12. s=s+x%10;
  13. x=x/10;}
  14. if(s>max1){
  15. max1=s;
  16. nmax=y;
  17.  
  18. }
  19. else
  20. if(s<min1){
  21. min1=s;
  22. nmin=y;
  23. }
  24.  
  25. }
  26. printf("Numere cu cifra max este=%d \n Numere cu cifra minima=%d",nmax,nmin);
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment