#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 балла, он не получит стипендию. a = [] d = 0 for i in range(int(input())): a.append(input()) c = set(a) for i in range(len(a)): if a[i] =='3': print('None') break if len(c) == 1 and a[0] == '5': print('Named') d = 0 break for x in a: d += int(x) if len(c) != 1 or a[0] != '5' and d // len(a) >= 4.5: print('High') break else: print('Common') break в чем ошибка Сделай так, запиши все элементы в массив, а затем выводи их с условием: 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 #include <iostream> #include <cmath> using namespace std; int main() { int n,s=0; bool f=0; float t; cin>>n; int M[n]; for( int i=0;i<n;i++) { cin>>M[i]; s+=M[i]; if(M[i]==3) f=1; } t=s/float(n); if(s/n==5) cout<<"Named"; else if(f==1 || t<4.5 ) cout<<"None"; else if(t>=4.5) cout<<"High"; } Nothing about the "common" scholarship... I don't understand what's wrong with my code #include <iostream> using namespace std; int main() { int n,i,mark; double t,coun; coun=0.0; cin >> n; for (i=0; i<n; i++) { cin >> mark; if (mark==3) t=0; coun+=mark; } if (t) {t=coun/n;} if (!t) { cout << "None";} if (t == 5) { cout << "Named"; } else if (t >= 4.5) { cout << "High"; } else if (t != 0) { cout << "Common"; } return 0; } n=int(input()) l=[int(input()) for _ in range(n)] items=sum(l) n=float(n) x=3.0 for i in l: try: i==x print ('None') if items/n==5 and i!=x: print 'Named'
elif (4.5<=(items/n)<5)and i!=x: print 'High'
elif ((items/n)<4.5)and i!=x: print 'Common' As easy as the problem this is, it took me 5 attempts to get it right only because the problem statement was unclear. Follow the more clear statement posted underneath this post. What is unclear? Could you post your last attempt and number of WA? 1)If a person has got satisfactory marks in any subject than answer will be "None". 2)If he has got marks greater than 5 in all sub than answer is "Named"; 3)If average score greater 4.5 than High; 4)Else common. I am not trying to spoil the question but I found statement little bit unclear.Hope thhis will help |
|