Advertisement
Josif_tepe

Untitled

Nov 12th, 2022
861
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(){
  3. int n,i,petki=0;
  4. scanf("%d", &n);
  5. int c1,c2,c3,c4;
  6. int k;
  7. float p;
  8.  
  9.  
  10.  
  11. c1=n/1000;
  12. c2=(n/100)%10;
  13. c3=(n/10)%10;
  14. c4=n%10;
  15.  
  16.  
  17.  
  18.     if(c1==5)
  19.     petki++;
  20.      if(c2==5)
  21.     petki++;
  22.      if(c3==5)
  23.     petki++;
  24.      if(c4==5)
  25.     petki++;
  26.  
  27.  
  28.  
  29.  
  30. if(c1==5){
  31.     c1+=1;}
  32. if(c2==5){
  33.     c2+=1;}
  34. if(c3==5){
  35.     c3+=1;}
  36. if(c4==5){
  37.     c4+=1;}
  38.  
  39.  
  40.  
  41. k=((c1*1000)+(c2*100)+(c3*10)+c4);
  42.  
  43.  
  44.  
  45. if(n>k){
  46.     p=((100.0*(n-k))/k);
  47. }
  48. if(n<k){
  49.     p=((100.0*(k-n))/n);
  50. }
  51. if(petki<2){
  52.     printf("Error");}
  53. else{
  54. printf("%.4f%%",p);
  55. }
  56. return 0;
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement