a = int(input()) f = [] for i in range(a): s = int(input()) f.append(s) if f.count(3) >=1: print('None') else: if f.count(5) == len(f): print('Named') elif sum(f) / len(f) >=4.5: print('High') else: print('Common') #include<iostream> #include<iomanip> #include<bits/stdc++.h> #include<string> using namespace std; int main(){ float n, k; int mark, a; a=0; k=0; cin >> n; for(int i=0; i<n; i++){ cin >> mark; a+=mark; } cout << fixed; cout << setprecision(1); k+=a/n; if(a%5==0 && mark>=5){ cout <<"Named" << endl; } else if(mark>3 && k>=4.5){ cout <<"High"<<endl; } else if(mark<=3){ cout <<"None" << endl; } else{ cout << "Common" << endl; } return 0; } #include <bits/stdc++.h> using namespace std; signed main(){ int n; cin>>n; int sum=0; for(int i=0;i<n;i++){ int x; cin>>x; sum+=x; } double cnt1=(double)sum/(double)n; if(cnt1==3){ cout<<"None"; }else if(cnt1==5){ cout<<"Named"; }else if(cnt1>=4.5 && cnt1!=5){ cout<<"High"; }else if(cnt1!=3 && cnt1!=5 && cnt1<4.5){ cout<<"Common"; } } getting a wrong answer on test 8 #include<stdio.h> int main() { int n,i,sum = 0; float res; scanf("%d",& n); int arr[n];
for(i = 1; i <= n; i++) { scanf("%d",&arr[i]); sum += arr[i]; } for(i = 1 ; i <= n; i++) { if(arr[i] == 3) { printf("None\n"); break; } }
res = (float)sum / n; if(res == 5) printf("Named\n"); else if(res >= 4.5) printf("High\n"); else if ((res < 4.5 && res >= 4)) printf("Common\n");
return 0; } using System; namespace a { class Program { static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine()); double[] A = new double[n]; double S = 0; for (int i = 0; i < n; i++) { A[i]=Convert.ToInt64(Console.ReadLine()); } for (int i = 0; i < n; i++) { S = S + A[i]; } double B = S / n; for (int i = 0; i < n; i++) { if (A[i] == 3) { Console.WriteLine("None"); goto finish; } } if (B >= 4.5) { Console.WriteLine("High"); goto finish; } for (int j = 0; j < n; j++) { if (A[j] == 5) { Console.WriteLine("Named"); goto finish; } } Console.WriteLine("Common"); finish: ; } } } #include <iostream> using namespace std; int main(){ int a,b = 0,c = 0,d = 0; int ocenki[20]; cin » a; for (int i = 1; i <= a; i++) cin » ocenki[i]; for (int i = 1; i <= a; i++){ if (ocenki[i] == 5){ b++; } else if (ocenki[i] == 4){ c++; } else if (ocenki[i] == 3){ d++; } } if (d > 0){ cout « "None" « endl; } else if (b == a){ cout « "Named" « endl; } else if (c > b){ cout « "Common" « endl; } else if (c = b){ cout « "High" « endl; } return 0; } #include <iostream> using namespace std; int main() { int m[10]{}, n; cin >> n; int sum = 0; for (int i = 0; i < n; i++) { cin >> m[i]; sum += m[i]; } double q; q = static_cast<double>(sum) / n; if (q == 4) { cout << "Common"; } if (q > 4.5 && q < 5) { cout << "High"; } if (q == 5) { cout << "Named"; } if (q == 3) { cout << "None"; } } if u wanna break your programm type sys.exit() (don't forget to type import sys in the beginning of the programm) _____________________ если вы хотите полностью прервать вашу программу, то импортируйте библиотеку sys и пропишите sys.exit() It took me a while to get this one correct, and it's because I found part of the descritpion to be ambiguous/unclear - so I'm posting this clarification which hopefully will help anyone else who has the same misunderstanding. "if a student has got satisfactory marks, the scholarship is not given, " I read this to mean "got ONLY satisfactory marks" but my solutions were rejected. Once I modified my solution to treat it as "got ANY satisfactory marks", the solution was accepted. dont use ',' use '.' at 4.5 Please read "if a student has got satisfactory marks, the scholarship is not given" this statement again and again which means if in any of the subject a student gets 3.0 he will not get any scholarship. -------------------------------------------------- Пожалуйста, прочитайте «если студент получил удовлетворительные оценки, стипендия не предоставляется», это утверждение снова и снова означает, что если по какому-либо предмету студент получает 3,0 балла, он не получит стипендию. deleted Edited by author 26.10.2021 22:50 Сделай так, запиши все элементы в массив, а затем выводи их с условием: if (massiv[i] == 3) a++(ну или a = a+1), я просто не знаю, на каком языке ты работал. Далее, если а больше 0, значит нет стипендии, ибо есть тройка. Потом также с 5 и 4. Если больше 4 так то так то, если 5 аналогично, а если нет троек и кол - во 4 равно кол - во 5, то так то так то Can someone give 5<sup>th</sup> test? I got WA5; var n,i,o,c,p,x:integer; s:real; begin s:=0;p:=0; readln(n); for i:=1 to n do begin readln(o); s:=s+o; end; s:=s/n; if o = 3 then begin inc(c); writeln('None'); end; if s=5 then if (c<>1) then begin inc(p); writeln('Named');end; if s>=4.5 then if (c<>1)and (p<>1) then begin inc(x); writeln('High'); end; if (c<>1) and (p<>1) and (x<>1) then writeln('Common'); end. Edited by author 05.04.2018 22:47 #include<stdio.h> int main() { int n , m , sum=0 ; double ava; scanf("%d",&n); int mark[11]; for(m=0;m<n;m++){ scanf("%d",&mark[m]); } for(m=0;m<n;m++){ sum=sum+mark[m]; } ava=(double)sum/n; if(ava<=3)printf("None\n"); else if (ava>=5)printf("Named\n"); else if(ava>=4.5)printf("High\n"); else printf("Common\n"); } #include <stdio.h> #include <stdlib.h> int main() { int a,p=0,i,*b; float f,s=0; scanf("%d",&a); b=(int *)malloc(sizeof(int)*a); for(i=0;i<a;i++){ scanf("%d",&b[i]);} /*if (b[i]<3||b[i]>5) scanf("%d",&b[i]); }*/ for(i=0;i<a;i++) s+=b[i]; f=s/a; for(i=0;i<a;i++) { if(b[i]==3){ p=1;} } if(f==5) {printf("Named"); } else if(f>=4.5&&p==0){ printf("High"); } else if(f<4.5&&p==0){ printf("Common");} else {printf("None");} free(b); return 0; } //I have correct in the IDE, what's wrong? import java.io.IOException; import java.util.Scanner; public class VasyaCare{ public static void main(String[] args) throws IOException { VasyaCare vasya_care = new VasyaCare(); Scanner scn = new Scanner(System.in); int n = scn.nextInt(); try{ // Check if(n < 10){ double[] b = vasya_care.setScore(n); double median = vasya_care.getMedian(b); if(median==3){ System.out.println("None"); } else if(median==5){ System.out.println("Named"); } else if(median >= 4.5){ System.out.println("High"); } else if(median < 4.5){ System.out.println("Common"); } } else throw new IOException("Please, type number from 1 to 10!"); } catch(Exception e){e = new IOException();} } double getMedian(double[] b{ // calculate median score of exam int sum = 0; for(int i = 0; i < b.length; i++){ sum = (int) (sum + b[i]); } return (double)sum/b.length; }
double[] setScore(int n){ // forming list scores Scanner scn = new Scanner(System.in); double[] b = new double[n];{ for(int j = 0; j < n; j++){ int m = scn.nextInt(); if(m<3 || m > 5){ System.out.println("Type score from 3 to 5: "); j--; } else if (m>=3 && m<=5){ b[j] = m; } } } return b; } } // Thank you for your attention! If Vasya has at least one note 3 scholarship is 'None'. So, 355555555... is no scholarship. Sorry if you considered that, I have read your code very careless. You're wrong, sorry, there is my testing: Input Type number exam: 8 Type score: 3 Type score: 5 Type score: 5 Type score: 5 Type score: 5 Type score: 5 Type score: 5 Type score: 5 3.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 average score: 4.75 Output: High I really don't understand, what's wrong. (( I have just copied code from my Accepted submissions. http://ideone.com/vWEL58I think the problem is easy enough To let post AC code be legal. You have "none" because your case "cur=int (input ()) if cur==3:..." does not check for the average score and passes at runtime immediately. You must check the average score in all cases, not the input variable. Are you a troll? That is Accepted code. If you copy & paste you AC. So there correct answer is "None" and dialog interface is not needed. Moreover, in most cases,there should be no dialog interface to get AC. Named avg =5 High avg>=4.5 not contain 3 nooooote that Common not 3 and less than 4.5 None not all of the above |
|