Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int n,i,petki=0;
- scanf("%d", &n);
- int c1,c2,c3,c4;
- int k;
- float p;
- c1=n/1000;
- c2=(n/100)%10;
- c3=(n/10)%10;
- c4=n%10;
- if(c1==5)
- petki++;
- if(c2==5)
- petki++;
- if(c3==5)
- petki++;
- if(c4==5)
- petki++;
- if(c1==5){
- c1+=1;}
- if(c2==5){
- c2+=1;}
- if(c3==5){
- c3+=1;}
- if(c4==5){
- c4+=1;}
- k=((c1*1000)+(c2*100)+(c3*10)+c4);
- if(n>k){
- p=((100.0*(n-k))/k);
- }
- if(n<k){
- p=((100.0*(k-n))/n);
- }
- if(petki<2){
- printf("Error");}
- else{
- printf("%.4f%%",p);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement