标签:lin end 空格 std ice double dad ++ getch
在这错过两次
错误输出:,后面要有一个空格 printf("%.2lf",maxprice); cout<<","<<max_s<<endl; printf("%.2lf",minprice); cout<<","<<min_s<<endl; 正确输出: printf("%.2lf",maxprice); cout<<", "<<max_s<<endl; printf("%.2lf",minprice); cout<<", "<<min_s<<endl;
ac代码:
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int main(){ int n; double price,maxprice=0,minprice=0; cin>>n; getchar(); string s,max_s,min_s; for(int i=1;i<=n;i++){ getline(cin,s); cin>>price; getchar(); // cout<<"sadad"<<price; if(i==1){ maxprice=price; minprice=price; max_s=s; min_s=s; }else{ //cout<<price<<" "<<maxprice<<" "<<minprice<<endl; if(price>maxprice){ maxprice=price;max_s=s; } if(minprice>price){ //cout<<"min"<<minprice<<price<<endl; minprice=price;min_s=s; } } } printf("%.2lf",maxprice); cout<<", "<<max_s<<endl; printf("%.2lf",minprice); cout<<", "<<min_s<<endl; }
标签:lin end 空格 std ice double dad ++ getch
原文地址:https://www.cnblogs.com/Aiahtwo/p/12452038.html