package study01; public class Even { public static void main(String[] args) { int sum = 0; for (int i = 1; i <= 100; i++) { if (i % 2 == 0) { sum += i; } } System.out.println(sum); } } 结果输出如下2550
var arr = [10,20,30]; //计数器思想 var sum = 0; for(var i=0;i<arr.length;i++){ sum += arr[i]; } console.log(sum); var avg = sum/arr.length; console.log(avg);
A. IQ test time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the givenn numbers differs from
原创作品,转载请注明出处:https://www.cnblogs.com/sunshine5683/p/9927186.html 今天在工作中遇到对一个已知的一维数组取出其最大值和最小值,分别用于参与其他运算,废话不多说,直接上代码. package xhq.text; public class Maxmin { static int count =0; public static void main(String args[]){ // 实例化对象 Maxmin maxmin = new Ma
方法一: Console.WriteLine("请输入三个数字:"); int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); int c = int.Parse(Console.ReadLine()); int max; if (a > b) { max = a; } else { max = b; } if (c > max) { Console.WriteLine(c)
private int GetModeNum(List<int> listValue) { List<int> listName = new List<int>(); //众数 List<int> listNum = new List<int>(); //众数的数量 ; foreach (var i in listValue) { ; if (!listName.Contains(i)) { foreach (var j in listValue
#include <iostream>using namespace std; int main(){ //求两数中的大者? int a,b; cin>>a>>b; if(a>b) cout<<"The max number is:"<<a; else cout<<"The max number is:"<<b;} method two: #include <iostre