Have you learned about loops yet? A loop would be much better suited to that code than using 'goto'. Not a bad first try, though.
char b;
int a;
begin:
Console.WriteLine("1+2=?");
a=Int32.Parse(Console.ReadLine());
switch (a)
{case 3:
Console.WriteLine("Congrategulation you are right");break;
default:
Console.WriteLine("wrong");break;}
Console.WriteLine("Y or N");
b=char.Parse(Console.ReadLine());
continue1:
switch(b)
{case 'Y':
goto begin;
case 'N':
Console.WriteLine("bye"); break;
default:
goto continue1;
break;
Console.WriteLine("Only Y and N is inputed");
}
static void Main(string[] args)
{
bool done = false;
while (!done)
{
Console.WriteLine("1 + 2 = ?");
if (int.Parse(Console.ReadLine()) != 3)
Console.WriteLine("Incorrect. Try again! :)");
else
{
Console.WriteLine("Correct! Good job. Quit? Y/N");
if (Console.ReadLine() == "Y".ToLower())
done = true;
}
}
}
public static List<Werkstoffpruefung> getTeilPruefungen(Teil teil,bool add_werkstoffe)
{
List<Werkstoffpruefung> wpruefungen = new List<Werkstoffpruefung>();
if (teil != null)
{
/*get data from our 'Teil'*/
PruefungsPaket paket = DBService.getPruefungsPaket(teil);
if (paket != null)
teil.PruefungsPaket = paket;
else
teil.PruefungsPaket = null;
if (teil.PruefungsPaket != null && teil.PruefungsPaket.WerkstoffPruefungen != null)
{
foreach (KeyValuePair<int, Werkstoffpruefung> werkprue in teil.PruefungsPaket.WerkstoffPruefungen)
{
Werkstoffpruefung pruefung = teil.PruefungsPaket.WerkstoffPruefungen[werkprue.Key];
if (!pruefung.Messergebnis.IsNull || !pruefung.MessergebnisChar.IsNull)
pruefung.ContainsData = true;
//pruefung.ContainsData = DBService.checkPruefungsErgebnis(pruefung.WerkstoffPruefungsID);
pruefung.Pruefungsergebnisse = DBService.getPruefungsergebnisse(ObjectType.WerkstoffPruefungen, pruefung.PruefungsID);
wpruefungen.Add(pruefung);
}
}
}
/*get data from 'Werkstoffe'*/
if (teil.Werkstoffe != null && add_werkstoffe == true)
{
foreach (Werkstoff werkstoff in teil.Werkstoffe)
{
TeilWerkstoffe teilw = DBService.getTeilwerkstoffe(teil.TeileID, werkstoff.WerkstoffID);
PruefungsPaket paket = DBService.getPruefungsPaket(ObjectType.Werkstoffe, teilw.TeilewerkstoffID);
if(paket != null && paket.PruefungsRelevant == 1 && paket.WerkstoffPruefungen != null)
{
foreach (KeyValuePair<int, Werkstoffpruefung> werkprue in paket.WerkstoffPruefungen)
{
Werkstoffpruefung pruefung = paket.WerkstoffPruefungen[werkprue.Key];
if (!pruefung.Messergebnis.IsNull || !pruefung.MessergebnisChar.IsNull)
pruefung.ContainsData = true;
//pruefung.ContainsData = DBService.checkPruefungsErgebnis(pruefung.WerkstoffPruefungsID);
pruefung.Pruefungsergebnisse = DBService.getPruefungsergebnisse(ObjectType.WerkstoffPruefungen, pruefung.PruefungsID);
wpruefungen.Add(pruefung);
}
}
}
}
return wpruefungen;
}
static void Main(string[] args)
{
bool done = false;
string input = "";
int number = 0, answer = 3;
while (!done)
{
Console.WriteLine("1 + 2 = ?");
input = Console.ReadLine();
if (int.TryParse(input, out number))
{
if (number != answer)
{
Console.WriteLine("Incorrect. Try again! :)");
}
else
{
Console.WriteLine("Correct! Good job.");
while (input != "Y".ToLower() && input != "N".ToLower())
{
Console.WriteLine("Quit? Y/N");
input = Console.ReadLine();
}
if (input == "Y".ToLower())
{
done = true;
}
}
}
else
{
Console.WriteLine("Please enter a number, not letters, or a mix.");
}
}
}
switch is more elegant when you´re checking multiple cases of the same type like numbers or whatever.But i not learnt loop yet
Dax but teacher told me the use of switch in console is more elegant than else if
switch(number)
{
case 1:
/*do something*/
break;
case 2:
/*do something*/
break;
case Default:
/*do something*/
break;
}
if(number == 1)
/*do something*/
else if(number == 2)
/*do something*/
else
/*do something*/
Atm C/C++, C#, VB/VB.Net, ASP.Net, some Javascript, a small knowledge in Java, PHP, Delphi, Objective-C and some rusty ASM(refreshing it atm) why???Thank u techno manhow many languge do u know
mmm C# is one of the best but i doubt its the best(at least for me). it actually pwns other languages in some areas but still need some more additions/changes.. anyways i wouldn´t skip C++ at all.. i recomend you to learn some C/C++ still at a later time if you wish. lots of code and stuff nowdays are done using pure C or just C++ and they may help you too. ASP.Net is nice too atm i master that language and it really allows you to do awesome stuff and by using AJAX and some Javascript you can do a lot of fancy stuff aswell... but as any other languages it has downsides too.My teacher told me c# is the best so i skip c++ in year 1 last year i am yet to learn java in year 3 and vb in year 4 all 4 years no asp and other like yours am i going the right direction
Well yeah, and Prolog is totally awesome, and Cobol is the r0x0rz... sad point is that they are application specific language (dynamic web pages/artificial intelligence/business servers) that people won't use unless they want to do something related to that application, and that however awesome we think they are people won't be interested into hearing our praises unless they are interested into the application in question.ASP.Net is nice too atm i master that language and it really allows you to do awesome stuff and by using AJAX and some Javascript you can do a lot of fancy stuff aswell... but as any other languages it has downsides too.
Well, as aruantek mentioned (what? wow! me agreeing with aruantek) this is not necessarely true. First of all, what is your major/what are you interested into?My teacher told me c# is the best so i skip c++ in year 1 last year i am yet to learn java in year 3 and vb in year 4 all 4 years no asp and other like yours am i going the right direction
Nice!I am done major in economic management now i am coputer science major in programming in year 2 now
package redblacksets;
import java.util.Collection;
import java.util.Iterator;
public class RedBlackSet<E extends Comparable<E>>
{
private RedBlackNode<E> root;
private boolean needsHeightAdjust;
public RedBlackSet()
{
root = null;
}
public RedBlackSet(E value)
{
root = null;
insert(value);
}
public RedBlackSet(Collection<E> c)
{
Iterator<E> i = c.iterator();
root = null;
while(i.hasNext())
{
insert(i.next());
}
}
public void insert(Collection<E> c)
{
Iterator<E> i = c.iterator();
while(i.hasNext())
{
insert(i.next());
}
if(root.colour == Colour.RED)
root.colour = Colour.BLACK;
}
public void insert(E value)
{
root = recInsert(value, root, null);
if(root.colour == Colour.RED)
root.colour = Colour.BLACK;
}
public String toString()
{
if(root == null)
return "null";
else return root.toString();
}
public RedBlackSet<E> union(RedBlackSet<E> set)
{
RedBlackSet<E> ret = new RedBlackSet<E>();
RedBlackIterator<E> i1 = getIterator();
RedBlackIterator<E> i2 = set.getIterator();
if(this.root == null)
return set.clone();
else if(set.root == null)
return this.clone();
E current1 = i1.next(), current2 = i2.next();
while(i1.hasNext() && i2.hasNext())
{
if(current1.equals(current2))
{
ret.insert(current1);
current1 = i1.next();
current2 = i2.next();
}
else if(current1.compareTo(current2) < 0)
{
ret.insert(current1);
current1 = i1.next();
}
else
{
ret.insert(current2);
current2 = i2.next();
}
}
if(!ret.member(current1))
ret.insert(current1);
if(!ret.member(current2))
ret.insert(current2);
while(i1.hasNext())
{
ret.insert(i1.next());
}
while(i2.hasNext())
{
ret.insert(i2.next());
}
return ret;
}
public RedBlackSet<E> difference(RedBlackSet<E> set)
{
RedBlackSet<E> ret = new RedBlackSet<E>();
RedBlackIterator<E> i1 = getIterator();
E current = i1.next();
while(i1.hasNext())
{
if(!set.member(current))
ret.insert(current);
current = i1.next();
}
return ret;
}
public RedBlackSet<E> symmetricDifference(RedBlackSet<E> set)
{
RedBlackSet<E> ret = new RedBlackSet<E>();
RedBlackIterator<E> i1 = getIterator();
RedBlackIterator<E> i2 = set.getIterator();
if(this.root == null)
return set.clone();
else if(set.root == null)
return this.clone();
E current1 = i1.next(), current2 = i2.next();
while(i1.hasNext() && i2.hasNext())
{
if(current1.equals(current2))
{
current1 = i1.next();
current2 = i2.next();
}
else if(current1.compareTo(current2) < 0)
{
ret.insert(current1);
current1 = i1.next();
}
else
{
ret.insert(current2);
current2 = i2.next();
}
}
if(!ret.member(current1))
ret.insert(current1);
if(!ret.member(current2))
ret.insert(current2);
while(i1.hasNext())
{
ret.insert(i1.next());
}
while(i2.hasNext())
{
ret.insert(i2.next());
}
return ret;
}
public RedBlackSet<E> intersection(RedBlackSet<E> set)
{
RedBlackSet<E> ret = new RedBlackSet<E>();
RedBlackIterator<E> i1 = getIterator();
RedBlackIterator<E> i2 = set.getIterator();
if(this.root == null || set.root == null)
return ret;
E current1 = i1.next(), current2 = i2.next();
while(i1.hasNext() && i2.hasNext())
{
if(current1.equals(current2))
{
ret.insert(current1);
current1 = i1.next();
current2 = i2.next();
}
else if(current1.compareTo(current2) < 0)
{
current1 = i1.next();
}
else
{
current2 = i2.next();
}
}
return ret;
}
public RedBlackSet<E> clone()
{
RedBlackSet<E> temp = new RedBlackSet<E>();
if(root == null)
return temp;
RedBlackIterator<E> i = getIterator();
while(i.hasNext())
temp.insert(i.next());
return temp;
}
/**
* Recursively inserts into a Red Black Tree
* @param value the value to be inserted
* @param node the node to insert into
* @return the new tree
*/
public RedBlackNode<E> recInsert(E value, RedBlackNode<E> node, RedBlackNode<E> parent)
{
if(node == null)
{
node = new RedBlackNode<E>(value, Colour.RED, parent);
}
else
{
if(node.equals(value))
return node;
else if(value.compareTo(node.value) < 0) //value less than node, insert into left subtree
{
if(node.left == null || node.left.colour == Colour.BLACK)
node.left = recInsert(value, node.left, node);
else
{
if(node.left.equals(value))
return node;
else if(value.compareTo(node.left.value) < 0) //insert into left grandchild
{
node.left.left = recInsert(value, node.left.left, node.left);
if(checkRotate(Rotate.LL, node.left))
{
rotate(Rotate.LL, node);
}
}
else //insert into right grandchild
{
node.left.right = recInsert(value, node.left.right, node.left);
if(checkRotate(Rotate.LR, node.left))
{
rotate(Rotate.LR, node);
}
}
}
}
else if(value.compareTo(node.value) > 0) //value greater than node, insert into right subtree
{
if(node.right == null || node.right.colour == Colour.BLACK)
node.right = recInsert(value, node.right, node);
else
{
if(node.right.equals(value))
return node;
else if(value.compareTo(node.right.value) < 0) //insert into left grandchild
{
node.right.left = recInsert(value, node.right.left, node.right);
if(checkRotate(Rotate.RL, node.right))
{
rotate(Rotate.RL, node);
}
}
else //insert into right grandchild
{
node.right.right = recInsert(value, node.right.right, node.right);
if(checkRotate(Rotate.RR, node.right))
{
rotate(Rotate.RR, node);
}
}
}
}
}
return node;
}
/**
* Tests if a rotate of a certain type is necessary
* @param type Rotate type
* @param start check for a rotate at this node
* @return true if rotate is needed, otherwise false
*/
private boolean checkRotate(Rotate type, RedBlackNode<E> start)
{
switch(type)
{
case LL:
{
if(start.colour == Colour.RED && start.left.colour == Colour.RED)
return true;
return false;
}
case LR:
{
if(start.colour == Colour.RED && start.right.colour == Colour.RED)
return true;
return false;
}
case RL:
{
if(start.colour == Colour.RED && start.left.colour == Colour.RED)
return true;
return false;
}
case RR:
{
if(start.colour == Colour.RED && start.right.colour == Colour.RED)
return true;
return false;
}
default: return false;
}
}
/**
* performs a rotate after insertion
* @param type type of rotate to perform
* @param start starting point
*/
private void rotate(Rotate type, RedBlackNode<E> start)
{
switch(type)
{
case LL:
{
RedBlackNode<E> temp = start.clone();
temp.parent = start;
if(temp.right != null)
temp.right.parent = temp;
temp.left = start.left.right;
if(temp.left != null)
temp.left.parent = temp;
start.value = start.left.value;
start.right = temp;
start.left = start.left.left;
start.left.parent = start;
}break;
case LR:
{
RedBlackNode<E> temp = start.clone();
RedBlackNode<E> temp2 = start.left.clone();
temp.parent = start;
temp2.parent = start;
if(temp.right != null)
temp.right.parent = temp;
temp.left = start.left.right.right;
if(temp.left != null)
temp.left.parent = temp;
if(temp2.left != null)
temp2.left.parent = temp2;
temp2.right = start.left.right.left;
if(temp2.right != null)
temp2.right.parent = temp2;
start.value = start.left.right.value;
start.left = temp2;
} break;
case RR:
{
RedBlackNode<E> temp = start.clone();
temp.parent = start;
if(temp.left != null)
temp.left.parent = temp;
temp.right = start.right.left;
if(temp.right != null)
temp.right.parent = temp;
start.value = start.right.value;
start.left = temp;
start.right = start.right.right;
start.right.parent = start;
}break;
case RL:
{
RedBlackNode<E> temp = start.clone();
RedBlackNode<E> temp2 = start.left.clone();
temp.parent = start;
temp2.parent = start;
if(temp.left != null)
temp.left.parent = temp;
temp.right = start.right.left.left;
if(temp.right != null)
temp.right.parent = temp;
if(temp2.right != null)
temp2.right.parent = temp2;
temp2.left = start.right.left.right;
if(temp2.left != null)
temp2.left.parent = temp2;
start.value = start.right.left.value;
start.right = temp2;
} break;
}
start.left.colour = Colour.BLACK;
start.colour = Colour.RED;
start.right.colour = Colour.BLACK;
}
public boolean member(E value)
{
RedBlackNode<E> node = root;
while(node != null)
{
if(node.value.equals(value))
return true;
else if(value.compareTo(node.value) < 0)
node = node.left;
else node = node.right;
}
return false;
}
public void delete(E value)
{
root = delete(value, root);
assert root.colour == Colour.BLACK;
assert checkColour(root);
assert checkBlackHeight(root);
}
private boolean checkBlackHeight(RedBlackNode<E> node)
{
if(node == null) return true;
int left = 0;
RedBlackNode<E> temp = node.clone();
while(temp.left != null)
{
temp = temp.left;
if(temp.colour == Colour.BLACK)
left++;
}
temp = node.clone();
int right = 0;
while(temp.right != null)
{
temp = temp.right;
if(temp.colour == Colour.BLACK)
right++;
}
return (right==left)&&checkBlackHeight(node.left)&&checkBlackHeight(node.right);
}
private RedBlackNode<E> delete(E value, RedBlackNode<E> node)
{
if(node == null)
{
needsHeightAdjust = false;
return node;
}
if(node.value.equals(value))
{
boolean left = false;
if(node != root) left = (node.parent.value.compareTo(node.value) > 0);
node = deleteThisNode(node);
node = rebalance(node,left);
}
else if(value.compareTo(node.value) < 0)
{
node.left = delete(value, node.left);
rebalance(node, true);
}
else
{
node.right = delete(value, node.right);
rebalance(node, false);
}
return node;
}
private RedBlackNode<E> deleteThisNode(RedBlackNode<E> node)
{
if(node.left == null && node.right == null) //adjustment required if node is black
{
needsHeightAdjust = (node.colour == Colour.BLACK);
node = null;
}
else if(node.left != null && node.right == null) //no adjustment required
{
node.value = node.left.value;
node.left = node.left.left;
node.right = node.left.right;
if(node.left != null) node.left.parent = node;
if(node.right != null) node.right.parent = node;
needsHeightAdjust = false;
}
else if(node.left == null && node.right != null) //no adjustment required
{
node.value = node.right.value;
node.left = node.right.left;
node.right = node.right.right;
if(node.left != null) node.left.parent = node;
if(node.right != null) node.right.parent = node;
needsHeightAdjust = false;
}
else
{
node.value = retLeftMost(node.right);
node.right = deleteLeftMost(node.right);
rebalance(node, false);
}
return node;
}
private E retLeftMost(RedBlackNode<E> node)
{
if(node.left == null)
{
return node.value;
}
else return retLeftMost(node.left);
}
private RedBlackNode<E> deleteLeftMost(RedBlackNode<E> node)
{
if(node.left == null)
{
node = deleteThisNode(node);
rebalance(node, true);
return node;
}
else
{
node.left = deleteLeftMost(node.left);
rebalance(node, true);
return node;
}
}
private RedBlackNode<E> rebalance(RedBlackNode<E> node, boolean isleft)
{
if(!needsHeightAdjust)
return node;
else if(node == null)
return node;
if(isleft)
{
if(node.right != null && node.right.colour == Colour.RED)
{
RedBlackNode<E> temp = node.clone();
if(temp.left != null)
{
temp.left.parent = temp;
}
temp.right = node.right.left;
if(temp.right != null)
temp.right.parent = temp;
node.value = node.right.value;
node.colour = Colour.BLACK;
temp.colour = Colour.RED;
node.left = temp;
temp.parent = node;
node.right = node.right.right;
if(node.right != null)
node.right.parent = node;
rebalance(temp, true);
rebalance(node, true);
}
else if(node.right != null && node.right.colour == Colour.BLACK &&
(node.right.left == null || node.right.left.colour == Colour.BLACK) &&
(node.right.right == null || node.right.right.colour == Colour.BLACK))
{
node.right.colour = Colour.RED;
if(node.colour == Colour.RED)
{
node.colour = Colour.BLACK;
needsHeightAdjust = false;
}
}
else if(node.right != null && node.right.colour == Colour.BLACK &&
(node.right.left == null || node.right.left.colour == Colour.BLACK))
{
RedBlackNode<E> temp = node.clone();
temp.right = node.right.left;
if(temp.right != null)
temp.right.parent = temp;
temp.parent = node;
temp.colour = Colour.BLACK;
node.value = node.right.value;
node.left = temp;
node.right = node.right.right;
node.right.parent = node;
node.right.colour = Colour.BLACK;
needsHeightAdjust = false;
}
else if(node.right != null && node.right.colour == Colour.BLACK &&
node.right.left.colour == Colour.RED)
{
RedBlackNode<E> temp = node.clone();
temp.colour = Colour.BLACK;
temp.right = node.right.left.left;
if(temp.right != null)
temp.right.parent = temp;
node.value = node.right.left.value;
temp.parent = node;
node.left = temp;
node.right.left = node.right.left.right;
if(node.right.left != null)
node.right.left.parent = node.right;
needsHeightAdjust = false;
}
}
else
{
if(node.left != null && node.left.colour == Colour.RED)
{
RedBlackNode<E> temp = node.clone();
if(temp.right != null)
{
temp.right.parent = temp;
}
temp.left = node.left.right;
if(temp.left != null)
temp.left.parent = temp;
node.value = node.left.value;
node.colour = Colour.BLACK;
temp.colour = Colour.RED;
node.right = temp;
temp.parent = node;
node.left = node.left.left;
if(node.left != null)
node.left.parent = node;
rebalance(temp, false);
rebalance(node, false);
}
else if(node.left != null && node.left.colour == Colour.BLACK &&
(node.left.left == null || node.left.left.colour == Colour.BLACK) &&
(node.left.right == null || node.left.right.colour == Colour.BLACK))
{
node.left.colour = Colour.RED;
if(node.colour == Colour.RED)
{
node.colour = Colour.BLACK;
needsHeightAdjust = false;
}
}
else if(node.left != null && node.left.colour == Colour.BLACK &&
(node.left.left == null || node.left.left.colour == Colour.BLACK))
{
RedBlackNode<E> temp = node.clone();
temp.left = node.left.right;
temp.colour = Colour.BLACK;
if(temp.left != null)
temp.left.parent = temp;
temp.parent = node;
node.value = node.left.value;
node.right = temp;
node.left = node.left.left;
node.left.parent = node;
node.left.colour = Colour.BLACK;
needsHeightAdjust = false;
}
else if(node.left != null && node.left.colour == Colour.BLACK &&
node.left.left.colour == Colour.RED)
{
RedBlackNode<E> temp = node.clone();
temp.left = node.left.right.right;
temp.colour = Colour.BLACK;
if(temp.left != null)
temp.left.parent = temp;
node.value = node.left.right.value;
temp.parent = node;
node.right = temp;
node.left.right = node.left.right.left;
if(node.left.right != null)
node.left.right.parent = node.left;
needsHeightAdjust = false;
}
}
return node;
}
private boolean checkColour(RedBlackNode<E> node)
{
if(node == null) return true;
if(node.left == null && node.right == null)
{
return true;
}
else if(node.colour == Colour.RED &&
((node.left != null && node.left.colour == Colour.RED) ||
(node.right != null && node.right.colour == Colour.RED)))
{
return false;
}
return checkColour(node.left)&&checkColour(node.right);
}
/**
* Returns an iterator for the set.
* @return an iterator for the current tree or null if the tree is null
*/
public RedBlackIterator<E> getIterator()
{
if(root == null)
return null;
return new RedBlackIterator<E>(this);
}
/**
*
* @author Anthony McCann 230077439
*
* @param <T> The type of object beign stored in the node, must be Comparable
*
* Red Black Node, the nodes store the values and from the tree
*/
private static class RedBlackNode<T extends Comparable<T>>
{
private RedBlackNode<T> left;
private RedBlackNode<T> right;
private RedBlackNode<T> parent;
private Colour colour;
private T value;
public RedBlackNode(T value, Colour colour, RedBlackNode<T> parent)
{
this.value = value;
this.colour = colour;
this.parent = parent;
left = null;
right = null;
}
public RedBlackNode<T> clone()
{
RedBlackNode<T> temp = new RedBlackNode<T>(value, colour, parent);
temp.left = left;
temp.right = right;
return temp;
}
public String toString()
{
String ret = "(";
ret += "(" + value.toString() + ", " + colour.toString() + ") ";
if(left != null)
ret += " " + left.toString();
else ret += " null";
if(right != null)
ret += " " + right.toString();
else ret += " null";
return ret += ")";
}
}
public static class RedBlackIterator<T extends Comparable<T>>
{
private java.util.Stack<RedBlackNode<T>> stack;
public RedBlackIterator(RedBlackSet<T> set)
{
stack = new java.util.Stack<RedBlackNode<T>>();
pushLeft(set.root);
}
private void pushLeft(RedBlackNode<T> node)
{
stack.push(node);
if(node.left != null)
pushLeft(node.left);
}
public T next()
{
RedBlackNode<T> temp = stack.pop();
if(temp.right != null)
pushLeft(temp.right);
return temp.value;
}
public boolean hasNext()
{
return !stack.isEmpty();
}
}
private static enum Colour
{
RED, BLACK;
}
private static enum Rotate
{
LL,LR,RR,RL;
}
}
Here's how I would do it(Spoiler tags, because if this is a homework assignment, you shouldn't be using it!):
No error checking, btw. I wanted to keep it simple.
Code:static void Main(string[] args) { bool done = false; while (!done) { Console.WriteLine("1 + 2 = ?"); if (int.Parse(Console.ReadLine()) != 3) Console.WriteLine("Incorrect. Try again! :)"); else { Console.WriteLine("Correct! Good job. Quit? Y/N"); if (Console.ReadLine() == "Y".ToLower()) done = true; } } }
__global__ static void combination(int* molecularPopulation,cType* reactionConstants,const int reduceMP,cType* result){
extern __shared__ int2 combi[];
const int block = (blockIdx.x);
const int reaction = block * blockDim.x + threadIdx.x;
if(reaction >= constrc)
return;
int factor1 = floor(reaction*0.25);
int factor2 = (reaction%4);
int maxFactor = blockDim.x *0.25;
cType loc = 1;
// int2* inputRow2 = (int2*)((char*)dependencyMatrix + dependencyPitch* factor1);
combi[factor1*4+factor2] = (factor2 < reduceMP) ? tex2D(dependencyMatrix2Texture,factor2,factor1) : make_int2(-1,0);
factor1 += maxFactor;
combi[factor1*4+factor2] = (factor2 < reduceMP) ? tex2D(dependencyMatrix2Texture,factor2,factor1) : make_int2(-1,0);
factor1 += maxFactor;
combi[factor1*4+factor2] = (factor2 < reduceMP) ? tex2D(dependencyMatrix2Texture,factor2,factor1) : make_int2(-1,0);
factor1 += maxFactor;
combi[factor1*4+factor2] = (factor2 < reduceMP) ? tex2D(dependencyMatrix2Texture,factor2,factor1) : make_int2(-1,0);
__syncthreads();
const cType molpol = ((combi[threadIdx.x*4]).y<0 && (combi[threadIdx.x*4]).x >= 0) ? (cType)molecularPopulation[(combi[threadIdx.x*4]).x] : 1.0f;
loc *= molpol;
if((combi[threadIdx.x*4]).y <= -2)
loc *= (molpol-1)/0.5;
const cType molpol2 = ((combi[threadIdx.x*4 + 1]).y<0 && (combi[threadIdx.x*4 + 1]).x >= 0) ? (cType)molecularPopulation[combi[threadIdx.x*4 + 1].x] : 1.0f;
loc *= molpol2;
loc *= reactionConstants[reaction];
result[reaction] = loc;
}
the main problem with the code you provided there is that its not going to loop and that´s ok but...."Houston we have problem"static void Main(string[] args) {
run();
}
static void run() {
Console.WriteLine("1 + 2 = ?");
if (int.Parse(Console.ReadLine()) != 3) Console.WriteLine("Incorrect. Try again!");
else Console.WriteLine("Correct! Good job. Quit? Y/N");
if (Console.ReadLine() == "Y".ToLower()) run();
}
I don't know if that's legal or not since I don't even know C# to begin with... but... I'd try it that way.Helps you learn about functions, too, and... it eliminates the loop and the loop check.
static void Main(string[] args) {
run();
}
static void run()
{
Console.WriteLine("1 + 2 = ?");
if (int.Parse(Console.ReadLine()) != 3)
{
Console.WriteLine("Incorrect. Try again! :)");
run();
}
else
Console.WriteLine("Correct! Good job. Quit? Y/N");
if (Console.ReadLine() != "Y".ToLower())
run();
}