2.4C语言 面对多行数据输入时,千万别忽略换行符...

#include     
    
int main() {    
    int n;    
    scanf("%d\n", &n);    
    for (int i = 0; i < n; i++)   
    {    
        char str;  
        double height;  
        scanf("%c %lf\n",&str,&height);//每一次输入有换行,记得跳过
        //printf("%.2lf",height);  
        if(str=='M')  
        {  
            double b_height=height/1.09;  
            printf("%.2lf\n",b_height);  
        }else if(str='F')
        {  
            double b_height=height*1.09;  
            printf("%.2lf\n",b_height);  
        }  
    }    
    return 0;    
}

忽略换行符导致改了半天....scanf和printf函数输入输出时别漏了\n...

你可能感兴趣的:(算法)