int min=ary[0]; int max =ary[0]; float sum =0; for(int j=1; j< loop ; j++){ if(ary[j]<min) min = ary[j]; if(ary[j]>max) max = ary[j]; sum += ary[j]; } cout<<"Min = "<<min<<endl; cout<<"Max= "<<max<<endl; printf("Avg= %.2f\n",(sum/loop));
int main(void){ int year; cin>> year; if(year%4==0 && year%100!=0||year%400==0) cout<<year<<" is Leap Year"<<endl; else cout<<year<<" is not Leap Year"<<endl;
import java.util.Scanner; import java.lang.Math.*; publicclass Q11461 { publicstaticvoid main(String args[]) { Scanner cin = new Scanner(System.in); while(cin.hasNextInt()){ int M = cin.nextInt(); int N = cin.nextInt(); if((M==0)&&(N==0)) break; int L = (int) Math.ceil(Math.sqrt(Math.min(M,N))); int U = (int) Math.floor(Math.sqrt(Math.max(M,N))); System.out.println(U-L+1); } } }
using System; using System.Collections.Generic; using System.Text; using System.Collections;
namespace ApplicantTestin { /// The DataObject class stored with a key class DataObject { // Populate privatestring keyStr; privatelong keyValue; privatebool keyStatus;
public DataObject(string inputKey) { keyStr = inputKey; }
publicstring Str { get { return keyStr; } } publiclong Val { get { return keyValue; } set { keyValue = value; } } publicbool Status { get { return keyStatus; } set { keyStatus = value; } }
/// <summary> /// Decrease the Value field by 1 of the /// data object stored with the key specified /// </summary> staticvoid Decrease(string key) { try { if (Data.ContainsKey(key)) {
/// <summary> /// Increase the Value field by 1 of the /// data object stored with the key specified /// </summary> staticvoid Increase(string key) { try { if (Data.ContainsKey(key)) { ((DataObject)Data[key.ToLower()]).Increase(); Console.WriteLine("Increment: "+ ((DataObject)Data[key.ToLower()]).Val); } } catch (Exception e) { Console.WriteLine(e); }
}
/// <summary> /// Prints the information in the Data hashtable to the console. /// Output should be sorted by key /// References should be printed between '<' and '>' /// The output should look like the following : /// /// /// Alpha...... -3 /// Bravo...... 2 /// Charlie.... <Zulu> /// Delta...... 1 /// Echo....... <Alpha> /// --etc--- /// /// </summary> staticvoid PrintSortedData() { ArrayList sortList = new ArrayList(); sortList.AddRange(Data.Keys); sortList.Sort(); foreach (string s in sortList) { DataObject obj = (DataObject)Data[s]; string tmpstr = s.Substring(0,1).ToUpper()+s.Substring(1,s.Length-1);
/// <summary> /// Prints the information in the Data hashtable to the console. /// Output should be sorted by stored value /// References should be printed between '<' and '>' /// Sorting order start from max to min, larger value takes priority. /// The output should look like the following : /// /// /// Bravo...... 100 /// Echo...... 99 /// Zulu...... 98 /// Charlie.... <Zulu> /// Delta...... 34 /// Echo....... 33 /// Alpha...... <Echo> /// --etc--- /// /// </summary> staticvoid PrintSortedDataByValue() { ArrayList sortlistValue = new ArrayList(); sortlistValue.AddRange(Data.Keys); for (int i = sortlistValue.Count-1; i > 0; i--) { for (int j = 0; j < i; j++) { if (((DataObject)Data[sortlistValue[j+1]]).Val > ((DataObject)Data[sortlistValue[j]]).Val){ string tmp = sortlistValue[j].ToString(); sortlistValue[j] = sortlistValue[j+1]; sortlistValue[j+1] = tmp; } }
}
Console.WriteLine("Sorted by value\n====================");
foreach (string s in sortlistValue) { DataObject obj = (DataObject)Data[s]; string tmpstr = s.Substring(0, 1).ToUpper() + s.Substring(1, s.Length - 1);
import java.util.Scanner; public class Q11417 { public static void main(String args[]) { Scanner cin = new Scanner(System.in); int count=0; while(cin.hasNextInt()){ int N = cin.nextInt(); if(N==0){ break; } count++; int G=0; for(int i=1;i< N;i++) for(int j=i+1;j<=N;j++) { G+=GCD(i,j); } System.out.println(G); } } public static int GCD(int x, int y) { int tmp; while (x % y != 0) { tmp = y; y = x % y; x = tmp; } return y; } }
import java.util.Scanner; public class Q11577 { public static void main(String args[]) { Scanner cin = new Scanner(System.in); int[] arrayd = new int[26]; int loop = Integer.parseInt(cin.nextLine().toString());
for(int j=1; j<=loop; j++) { int max=0; for(int p =0; p<26; p++){ arrayd[p]=0; } String line = cin.nextLine(); char[] ca = line.toCharArray();
for(int i=0; i< ca.length; i++){ if(ca[i]<= 90 && ca[i]>=65){ int tmpval = (int)ca[i]-65; arrayd[tmpval]++; if(arrayd[tmpval] > max){ max = arrayd[tmpval]; } }else if (ca[i]<= 122 && ca[i]>=97){ int tmpval = (int)ca[i]-97; arrayd[tmpval]++; if(arrayd[tmpval] > max){ max = arrayd[tmpval]; } } }
for(int p =0; p<26; p++){ if(arrayd[p]==max){ System.out.print((char)(p+97)); } }
public static void main(String args[]){ Scanner cin = new Scanner(System.in); String inputLine; while (cin.hasNextLine()){ int count =0; int max =0; ArrayList as = new ArrayList();
boolean flag = true; inputLine = cin.nextLine(); String[] tokens = inputLine.split(" "); count = Integer.parseInt(tokens[0]); for (int i=1 ;i < tokens.length; i++) { if(Integer.parseInt(tokens[i])> max){ max = Integer.parseInt(tokens[i]); }