#includeCode 2using namespace std; int main() { int n; cin>>n; int greatCount = 0; int goodCount = 0; int i = 0; while(i >grade; if(grade>=60) goodCount++; if(grade>=85) greatCount++; i++; } float good = 100.0*goodCount/n; float great = 100.0*greatCount/n; printf("%.0f%n",good); printf("%.0f%n",great); return 0; }
round()四舍五入函数
#include#include using namespace std; int main() { int n; cin>>n; int greatCount = 0; int goodCount = 0; int i = 0; while(i >grade; if(grade>=60) goodCount++; if(grade>=85) greatCount++; i++; } cout << round(100.0 * goodCount / n) << "%" << endl; cout << round(100.0 * greatCount / n) << "%" << endl; return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)