Hi,
I'd like to know a possible algorithm to calculate all possible combinations, without repetitions, starting from length=1 until lenght=N of N elements.
Example:
Elements: 1, 2, 3.
Output:
1
2
3
12
13
23
123
...
#include <stdio.h>
void main(void)
{
int i;
char c;
for (i=0;i <5;i++)
{
scanf("%d",&c);
printf("i=%d\r\n",i);
}
printf("The loop is finished!\r\n");
}
Especially the scanf function...
Can you give detailed explanation?
...
I have a string, and another text file which contains a list of strings.
We call 2 strings "brotherhood strings" when they're exactly the same after sorting alphabetically.
For example, "abc" and "cba" will be sorted into "abc" and "abc", so the original two are brotherhood. But "abc" and "aaa" are not.
So, is there an efficient way t...
Hey, I'm trying to create a basic program that will generate a number based on variables entered by the user. The formula is
a = b / (c * d)
This is a formula for finding specific heat, whereas b=energy, c=mass, and d= change in temperature.
So my problem is that I'm not making this program for myself, otherwise I could just assign ...
Ok I'm doing this programming assignment and need a little help.
Here is the problem:
Given three ints, a b c, return true if it is possible to add two of the ints to get the third.
twoAsOne(1, 2, 3) → true
twoAsOne(3, 1, 2) → true
twoAsOne(3, 2, 2) → false
Here's the what I have gotten so far:
public boolean twoAsOne(int a, int b,...
I got a new project from my teacher to convert database to another. How can I convert a MS SQL database into MYSQL using JAVA
...
This is a homework question, but I really just need some hints, that's all.
Basically, I need to create this function flat that's supposed to re-contract a new list from the input list (but here, the input list can have a nested list inside):
ex. flat of (A (B (C) D) A) is (A B C D A)
My algorithm is the following, not sure if it's co...
Another hw question, here is what I have so far. My Goal is to make the function part? return true if a list or an item is inside the nested list.
But so far I can only get it working with signal item inside a first order list. (not nested list yet)
(define part?
(lambda (item l)
(and (not (null? l))
(or (= item (car l...
Trying to write out a simple C Calculator script, using only the basic +, -, /, *. I have the following but not sure why it's not printing correctly. Any experienced C users out there?
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
//introduce vars
double number1, number2, result;
char symbol; //the operator *, -, ...
i want to create an application that will keep track of a supermarkets inventory
*the [products must be read from an Ms Access database
*product class must be created which will store all the data about a type of product(e.g. name,brand,price)
*a custom control must be used to display/update product details
*the database must be apdated ...
This is for a friend of mine who is having trouble with Java for school. I do know some programming, but not Java.
Scanner kbReader = new Scanner(System.in);
System.out.print("Name of item: ");
String name = kbReader.next();
System.out.println("Original price of item: $");
double price = kbReader.nextDouble();
Outputs:
Name of item:...
int main(void) {
char x;
int y=1280;
x=y;
printf("%d", x);
}
OUTPUT: 0
I remember that int = 4 byte and char is merely 1 byte. So we're trying to squeeze a 4 byte data into a 1 byte space, but why is the output 0??
...
The problem is to learn computer to do addition.
Computer have as input a knowladge of a numbers: he "knows" that after 1 goes 2, after 2 goes 3 and so on... Having that data computer can easyly get next number.
Next, computer have knowlandge as input that x+0=x and x+(y+1)=(x+1)+y. This axioms let computer to do addition. For example, t...
How do I convert an integer to a list and back in Oz? I need to take a number like 321 and reverse it into 123. The Reverse function in Oz only works on lists so I want to convert 321 to [3 2 1], reverse it, and convert [1 2 3] back to 123. Can this be done in Oz?
...
Hey,
I'm working on a simple project to create tables and insert data into them, and finally execute some queries. Please note: I'm using MySQL command client.
My schema is easy to implement; it's no problem.
Emp(eid: integer, ename: string, age: integer, salary: real)
Works(eid: integer, did: integer, pct_time: integer)
...
I am trying to convert from any base to base 10. For an input of 010111 base 2 it gives me 1, and for 35 base 9 it gives me 18 which should be 38. Any suggestions?
#include<stdio.h>
#include<math.h>
#include<string.h>
#define LENGTH 6
double pow( double x, double power );
int main()
{
char input[LENGTH+1] ;
int base;
unsi...
Please can anyone tell me what is the error in the following piece of code?
Question is
Create a class person which has
A variable ‘name’ which stores the name of the person.
A constructor that takes a single argument that is used to initialize the name variable
A method getName() which displays the name.
A protected method setName()...
I'm working on a school project in eclipse, and when I try and use the isEmpty() method on a String, Eclipse shows up the following error:
"The method isEmpty() is undefined for the type String"
I've run the Java updates, but am still getting it. Is any reason why this method would be undefined?
...
Hey guys,
I'm working on a c++ program and I need to take in a binary number from 0-255, inclusive, as a string(it has to be a string). What can I write in a while(input invalid) loop to check that the string is between 00000000 to 11111111, inclusive. Thanks so much
...
Consider the following implementation of bucket-sort:
Algorithm BucketSort(S)
input: Sequence S of items with integer keys in range [0,N-1]
output: Sequence S sorted in nondecreasing order of keys.
let B be an array of N sequences, each of which is initially empty
for each item x in S do
let k be the key of x
...