נשלח: מאנטאג נאוועמבער 17, 2014 9:03 pm
וועט זיך לכאורה אויך ווענדן צו די קאמפיוטער נוצט א CISC אדער RISC סי פי יו, ניין?
http://vps9000.inmotionhosting.com/~kavesh6/
http://vps9000.inmotionhosting.com/~kavesh6/viewtopic.php?t=7547
יידל האט געשריבן:וועט זיך לכאורה אויך ווענדן צו די קאמפיוטער נוצט א CISC אדער RISC סי פי יו, ניין?
קוד: וועל אויס אלע
1000 *
1001
____
1000
0000
0000
1000
_______
1001000
פארוואס? האט געשריבן:יאיר האט געשריבן:פארוואס?, יידל רעדט פון עפעס אנדערש. דוק ותשכח.
דוקתי ולא שכחתי.
ער רעדט פון צוזאמרעכענען די סומע פון אלע קלענערע נומערן קלענער פון n. עם איי מיסינג סאמטינג?
קול דודי האט געשריבן:דא:
http://www.counton.org/timeline/test-ma ... carl-gauss
א לופ איז טאקע נישט אזוי גוט דא, ווייל עס נעמט O(N) צייט. דהיינו ווי גרעסער די נאמבער אלס לענגער נעמט עס. משא״כ די פארמולא איז אין קאנסטענט טיים, דהיינו ס׳ווערט נישט ערגער מיט גרעסערע נאמבערס.
פארוואס? האט געשריבן:וואס מיינסטו צו זאגן. ווען n איז גרעסער, איז די מולטיפליקעישן פראסעס נישט גרעסער?
קוד: וועל אויס אלע
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.println("enter a number");
int input = s.nextInt();
System.out.println("enter the base");
boolean repeat;
do
{
int base = s.nextInt();
repeat = false;
if (base <2)
{
System.out.println("Enter a base greater than one");
repeat = true;
}
}while (repeat);
String result = "";
while (input > 0)
{
int binary = input%base;
String myResult;
if (binary >= 10)
{
switch (binary)
{
case 10: myResult = "A";
break;
case 11: myResult = "B";
break;
case 12: myResult = "C";
break;
case 13: myResult = "D";
break;
case 14: myResult = "E";
break;
case 15: myResult = "F";
break;
case 16: myResult = "H";
break;
case 17: myResult = "!";
break;
case 18: myResult = "J";
break;
case 19: myResult = "K";
break;
case 20: myResult = "L";
break;
default: myResult = "error";
}
}
else myResult = Integer.toString(binary);
result = result + myResult;
input = input/base;
}
String finalResult = new StringBuilder(result).reverse().toString();
System.out.println("In base "+ base +" it is: " +finalResult);
}
קול דודי האט געשריבן:chusid האט געשריבן:ווי האט עטץ ענק געלערנט קוידס? איז דאס א קאמפלאצירטע לימוד?
נישט זייער קאמפליצירט. הלא הם כתובים בספרי קאמפיוטער פראגרעמינג ואפשר להשיגם בניקל.
קוד: וועל אויס אלע
var matrix1 = [[7, 8], [9, 10], [11, 12]];
var matrix2 = [[1, 2, 3],[4, 5, 6]];
var result = [];
for(var i = 0; i < matrix1[0].length; i++){
result[i] = [];
for(var k = 0; k < matrix2.length; k++){
result[i][k] = 0;
for(var j = 0; j < matrix1.length; j++){
result[i][k] += matrix2[i][j] * matrix1[j][k];
}
}
};
קוד: וועל אויס אלע
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Let's multiply matrices."
+ "\nPlease Enter the number of Rows for matrix A:");
int rowsA = sc.nextInt();
System.out.println("Next, enter the number of Columns for matrix A:");
int columnsA = sc.nextInt();
System.out.println("Now enter the number of rows for matrix B:");
int rowsB = sc.nextInt();
System.out.println("Finally, enter the number"
+ " of columns for matrix B:");
int columnsB = sc.nextInt();
if (columnsA != rowsB)
System.out.println("Undefined. Columns of A has to be the same"
+ " as rows of B.");
else
{
double[][] matrixA = new double[rowsA][columnsA];
double[][] matrixB = new double[rowsB][columnsB];
double[][] matrixAB = new double[rowsA][columnsB];
System.out.println("Matrix A:");
for (int i = 0; i < matrixA.length; i++)
{
for (int j = 0; j < matrixA[i].length; j++)
{
System.out.println("Row " + (i+1) +", Column" + (j+1) + ":");
matrixA[i][j] = sc.nextDouble();
}
}
System.out.println("Matrix B:");
for (int i = 0; i < matrixB.length; i++)
{
for (int j = 0; j < matrixB[i].length; j++)
{
System.out.println("Row " + (i+1) +", Column" + (j+1) + ":");
matrixB[i][j] = sc.nextDouble();
}
}
for (int i = 0; i < matrixA.length; i++)
{
for (int k = 0; k < matrixB[0].length; k++) //is matrixB[k] valid?
{
for (int j = 0; j < matrixB.length; j++)
{
matrixAB[i][k] += matrixA[i][j]*matrixB[j][k];
}
}
}
System.out.println("Matrix A times matrix B equals:");
for (int i = 0; i < matrixAB.length; i++)
{
for (int j = 0; j < matrixAB[i].length; j++)
{
System.out.print("Row " + (i+1) +", Column " + (j+1) + ": ");
System.out.printf("% -10.2f\t", matrixAB[i][j]);
}
System.out.println("");
}
}
}
פארוואס? האט געשריבן:למעשה האב איך פראבירט זוכן ווי אזוי דער קאמפיוטער טוהט מאלטיפליקעישן, זעה איך אז ער טוהט עס זייער גרינג, לאמיר נעמען די פריערדיגע דוגמא 8*9
קוק נאר:
[left][/left]קוד: וועל אויס אלע
1000 *
1001
____
1000
0000
0000
1000
_______
1001000
יאיר האט געשריבן:איך מיין דער פארמולא דארף זיין 2/(99*100).
דער הסבר פון דער פארמולא איז ווי פאלגנד:
ביי יעדער הענדשעיק זענען דא צוויי מענטשן וואס נעמען אנטייל אין דעם שפיל, דער נותן און דער מקבל. יעצט, וויפיל סארט צוזאמענשטעלן פון הענדשעיקס קענען מיר מאכן אין א צימער פון הונדערט מענטשן? דאס צו ענטפערן דארפן מיר וויסן וויפיל נותנים קענען זיין און וויפיל מקבלים קענען זיין. נותנים קענען זיין הונדערט, ווייל אזויפיל מענטשן זענען דא און יעדער קען געבן א הענדשעיק. מקבלים קענען נאר זיין ניין און ניינציג, ווייל איינמאל איין מענטש ווערט א נותן בלייבט איבער 99 וואס קענען מקבל זיין. ממילא האבן מיר א סך הכל פון 9900 הענדשעיקס וואס קענען פארקומען אין דעם שטוב. אבער אזוי ווי מיר ווילן נישט אז די זעלבע צוויי מענטשן זאלן זיך איבערגעבן שלום עליכם, דארף מען צוטיילן דעם נומער אין צוויי, וואס איז דער ענדגילטיגער סך הכל.
קוד: וועל אויס אלע
/** Roman Number system class **/
import java.util.Scanner;
class Main
{
public static void main(String[] args)
{
System.out.println("Please enter a decimal year, between 1 and 3999, that you wish to convert to roman numerals : ");
Scanner scan = new Scanner(System.in);
int n=scan.nextInt();
if ((n>=1)&&(n<=3999)){
int year=n;
String romanOnes=romanDigit(n % 10, "I", "V", "X");
n=n/10;
String romanTens=romanDigit(n % 10, "X", "L", "C");
n=n/10;
String romanHundreds=romanDigit(n % 10, "C", "D", "M");
n=n/10;
String romanThousands=romanDigit(n % 10, "M", "M", "M"); //M can be repeated in all 3 since we've put a cap so that 4000 cannot be converted
// output value returned from method
System.out.println("Year " + year + " converted to Roman numerals is " + romanThousands+romanHundreds+romanTens+romanOnes);
}
else {
System.out.println("The year that you've entered is either less than 1 or more than 3999");
}
}
public static String romanDigit(int n, String one, String five, String ten){
String roman="";
if (n==1)
{roman+=one;}
else if (n==2)
{roman+=one+one;}
else if (n==3)
{roman+=one+one+one;}
else if (n==4)
{roman+=one+five;}
else if (n==5)
{roman+=five;}
else if (n==6)
{roman+=five+one;}
else if (n==7)
{roman+=five+one+one;}
else if (n==8)
{roman+=five+one+one+one;}
else if(n==9)
{roman+=one+ten;}
else; // if n==0, roman returns empty
return roman;
}
}
קוד: וועל אויס אלע
integer=int(input("Please enter an integer"))
while integer>0:
i=2
while i<integer and integer%i!=0:
i=i+1
if i==integer:
print(integer, "is a prime")
integer=integer-1
קוד: וועל אויס אלע
class Main
{
public static void main(String[] args)
{
String s="1";
int n=18;
int i=2;
while (i<=n)
{
if (n%i==0)
s=s+" "+ i;
i=i+1;
}
System.out.println("Result:" +s);
}
}
קוד: וועל אויס אלע
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
final int SIZE =5;
int[] anArray = new int[SIZE];
int arraySum_=0;
Scanner scan = new Scanner(System.in);
int input, result, alternateSum;
for (int i=0; i<anArray.length; i++){
System.out.print("Please enter integer " + (i+1)+":");
input=scan.nextInt();
anArray[i]=input;
}//for ends
String message="The values you have entered are ";
printArrayElements(message, anArray);
arraySum_=arraySum(anArray);
int[] Sum = new int[1];
Sum[0]=arraySum_;
message="The sum of the values you have entered is ";
printArrayElements(message,Sum);
message="The sum of the values in the odd indexes - those in the even indexes is ";
Sum[0]=altSum(anArray);//reusing the array Sum and overriding what was stored there i.e. the sum of all inputs.
printArrayElements(message,Sum);
message="The values you have entered, in reverse order are";
anArray=reverseArray(anArray);
printArrayElements(message,anArray);
}//first method(main) ends
public static void printArrayElements(String message, int[] arrayToPrint){
if (arrayToPrint.length>1){
System.out.println(message + " "+ Arrays.toString(arrayToPrint));}
else
System.out.println(message + " "+ arrayToPrint[0]);
}//second method ends
public static int arraySum(int[] incomingArray)
{
int total=0;
int l= incomingArray.length;
if (l>0)
for (int i=0; i<incomingArray.length; i++){
total=total+incomingArray[i];
}
return total;
}//third method ends
public static int altSum(int[] incomingArray){
int evenTotal=0;
int oddTotal=0;
int l= incomingArray.length;
if (l>=2){
for (int i=1; i<=incomingArray.length; i+=2){
if (i<incomingArray.length){
evenTotal=evenTotal+incomingArray[i];
oddTotal=oddTotal+incomingArray[i-1];}
else{oddTotal=oddTotal+incomingArray[i-1];}
}
}
else if (l<2)
oddTotal=incomingArray[0];
return oddTotal-evenTotal;//for ends
}//forth method ends
public static int[] reverseArray(int[] data){
int[] arrayReversed = new int[data.length];
int i=data.length-1;
for(int c=0; c<data.length; c++){
arrayReversed[c]= data[i];
i--;
}
return arrayReversed;
}//fifth method ends
}//class ends
קוד: וועל אויס אלע
class Main {//Powers
public static void main(String[] args) {
long results=0;
int base=2;
System.out.println(base+"^0" +"="+1);//for base^0
System.out.println(base+"^1="+ base);
results=(base*base);
System.out.println(base+"^2="+results);
for (int exponent=3; exponent<=40; exponent++)
{
results=(results*base);
System.out.println(base+"^" + exponent +"=" +results);
}
}
}