Saturday, April 6, 2013

Problem With Reading Character 'X' From Array - C And C++ ...


Example
#{example}
"); ipb.editor_values.get('templates')['togglesource'] = new Template("
??? Cancel Source Edit
"); ipb.editor_values.get('templates')['toolbar'] = new Template(""); ipb.editor_values.get('templates')['button'] = new Template("
  • Icon
  • "); ipb.editor_values.get('templates')['menu_item'] = new Template("
  • #{title}
  • "); ipb.editor_values.get('templates')['togglesource'] = new Template("
    ??? Cancel Source Edit
    "); ipb.editor_values.get('templates')['emoticons_showall'] = new Template(""); ipb.editor_values.get('templates')['emoticon_wrapper'] = new Template("

    Emoticons

    "); // Add smilies into the mix ipb.editor_values.set( 'show_emoticon_link', false ); ipb.editor_values.set( 'bbcodes', $H({"snapback":{"id":"1","title":"Post Snap Back","desc":"This tag displays a little linked image which links back to a post - used when quoting posts from the board. Opens in same window by default.","tag":"snapback","useoption":"0","example":"[snapback]100[/snapback]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"topic":{"id":"5","title":"Topic Link","desc":"This tag provides an easy way to link to a topic","tag":"topic","useoption":"1","example":"[topic=1]Click me![/topic]","switch_option":"0","menu_option_text":"Enter the topic ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"post":{"id":"6","title":"Post Link","desc":"This tag provides an easy way to link to a post.","tag":"post","useoption":"1","example":"[post=1]Click me![/post]","switch_option":"0","menu_option_text":"Enter the Post ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"spoiler":{"id":"7","title":"Spoiler","desc":"Spoiler tag","tag":"spoiler","useoption":"0","example":"[spoiler]Some hidden text[/spoiler]","switch_option":"0","menu_option_text":"","menu_content_text":"Enter the text to be masked","single_tag":"0","optional_option":"0","image":""},"acronym":{"id":"8","title":"Acronym","desc":"Allows you to make an acronym that will display a description when moused over","tag":"acronym","useoption":"1","example":"[acronym='Laugh Out Loud']lol[/acronym]","switch_option":"0","menu_option_text":"Enter the description for this acronym (EG: Laugh Out Loud)","menu_content_text":"Enter the acronym (EG: lol)","single_tag":"0","optional_option":"0","image":""},"hr":{"id":"12","title":"Horizontal Rule","desc":"Adds a horizontal rule to separate text","tag":"hr","useoption":"0","example":"[hr]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"1","optional_option":"0","image":""},"php":{"id":"14","title":"PHP Code","desc":"Allows you to enter PHP code into a formatted/highlighted syntax box","tag":"php","useoption":"0","example":"[php]$variable = true;\n\nprint_r($variable);[/php]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"html":{"id":"15","title":"HTML Code","desc":"Allows you to enter formatted/syntax-highlighted HTML code","tag":"html","useoption":"0","example":"[html]\n \n[/html]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"sql":{"id":"16","title":"SQL Code","desc":"Allows you to enter formatted/syntax-highlighted SQL code","tag":"sql","useoption":"0","example":"[sql]SELECT p.*, t.* FROM posts p LEFT JOIN topics t ON t.tid=p.topic_id WHERE t.tid=7[/sql]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"xml":{"id":"17","title":"XML Code","desc":"Allows you to enter formatted/syntax-highlighted XML code","tag":"xml","useoption":"0","example":"[xml]\n \n Test\n \n[/xml]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"member":{"id":"31","title":"Member","desc":"Given a member name, a link is automatically generated to the member's profile","tag":"member","useoption":"1","example":"[member=skyhawk133] runs this site.","switch_option":"0","menu_option_text":"Input Username of Member","menu_content_text":"","single_tag":"1","optional_option":"0","image":"memberbbcode.png"},"extract":{"id":"33","title":"Extract Blog Entry","desc":"This will allow users to define an extract for an entry. Only this piece of the entry will be displayed on the main blog page and will show up in the RSS feed.","tag":"extract","useoption":"0","example":"[extract]This is an example![/extract]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"blog":{"id":"34","title":"Blog Link","desc":"This tag provides an easy way to link to a blog.","tag":"blog","useoption":"1","example":"[blog=100]Click me![/blog]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"entry":{"id":"35","title":"Blog Entry Link","desc":"This tag provides an easy way to link to a blog entry.","tag":"entry","useoption":"1","example":"[entry=100]Click me![/entry]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"twitter":{"id":"36","title":"Twitter","desc":"A tag to link to a user's twitter account","tag":"twitter","useoption":"0","example":"[twitter]userName[/twitter]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":"twitter.png"},"inline":{"id":"37","title":"Inline Code","desc":"Formats code inline instead of in a seperate code box. ","tag":"inline","useoption":"0","example":"[inline]style=\"font-size: 12px;\"[/inline]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"il":{"id":"38","title":"Abbreviated Inline (IL)","desc":"Abbreviated version of the [inline] tag. ","tag":"il","useoption":"0","example":"[il]Code Here[/il]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":"il2.png"},"code":{"id":"41","title":"Code","desc":"Allows you to enter general code","tag":"code","useoption":"1","example":"[code]$text = 'Some long code here';[/code]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"1","image":""}}) ); ipb.vars['emoticon_url'] = "http://cdn.dreamincode.net/forums/public/style_emoticons/default"; //Search Setup ipb.vars['search_type'] = 'forum'; ipb.vars['search_type_id'] = 15; ipb.vars['search_type_2'] = 'topic'; ipb.vars['search_type_id_2'] = 317778; //]]>

    5 Replies - 59 Views - Last Post: Yesterday, 11:57 PM Rate Topic: -----

    #1 babyhands ?Icon User is offline

    Reputation: 0

    • Posts: 7
    • Joined: 02-April 13

    Posted Yesterday, 09:25 PM

    Hey guys, so if you guys saw my post a little while back I am writing a program that takes in 10 digit ISBN numbers in the form of strings, I then check the ISBN to see if its valid, and then i print out if it is valid or not. Basically, if an 'X' appears in the ISBN as the last digit, it is supposed to assign that index in the array to the value of 10, and if 'X' is any where else in the array the ISBN is invalid. Here is My code:
    
#include <iostream> #include <string>  using namespace std;  int main() { 	int keep = 0; 	string isbn[20]; do{          cin >> isbn[keep];        } while (isbn[keep][0] != 4 && keep++ < 20);        for (int i = 0; i < keep; i++){ //looping through all of the strings      int save = 0; 	int partial[10]; for (int k = 0; k < isbn[i].length(); k++){ //looping through all of the characters 	        if ((isbn[i][k] >= '0' && isbn[i][k] <= '9') || (save == 10 && isbn[i][k] == 'X')){ //checking if ISBN is valid 		   int next = 0; 		   if (isbn[i][k] == 'X') 			   partial[save] = 10; 		   else 			   next = (int)(isbn[i][k] - '0'); 		   if (save == 0) 			   partial[save] = next; 		   else  			   partial[save] = partial[save-1] + next;               		   save++;  	   }  	   else if (isbn[i][k] != '-'){  		   cout << isbn[i][k] << " is not valid" << endl;  		   break;  	   } 	          } int use = partial[0]; for (int j = 0; j < 9; j++){ use += partial[j + 1]; } if (use % 11 == 0){ cout << isbn[i] << " is valid." << endl; } else 	cout << isbn[i] << " is not valid" << endl; }   } 

    Basically, it works for all ISBN's except for the ISBN's with the X as the last digit. It will just print out X is invalid, so for some reason it isn't getting picked up in my big if statement. What do you guys think is causing this issue? Could it be that it is just reading the first part of the if and not looking at the second part of the if statement? I tried changing it to save == 9, and this time it doesnt print out X is invalid, but still says that the isbn number is invalid. Two ISBN's you guys can try are 0 1 3 1 6 2 9 5 9 X or 0-1315-2447-X (dashed don't matter).

    Thanks!


    Is This A Good Question/Topic? 0

    Replies To: Problem with reading character 'X' from array

    #2 babyhands ?Icon User is offline

    Reputation: 0

    • Posts: 7
    • Joined: 02-April 13

    Re: Problem with reading character 'X' from array

    Posted Yesterday, 09:38 PM

    (and if you are testing the code and wondering how to stop entering the ISBN's, type ctrl + D and hit enter and it will drop you out of the loop)


    #3 Skydiver ?Icon User is online

    Reputation: 1736

    • Posts: 5,142
    • Joined: 05-May 12

    Re: Problem with reading character 'X' from array

    Posted Yesterday, 09:42 PM

    It's not the root cause of your problem, but you do have a problem of overrunning your array in the loop on lines 50-52.


    #4 Skydiver ?Icon User is online

    Reputation: 1736

    • Posts: 5,142
    • Joined: 05-May 12

    Re: Problem with reading character 'X' from array

    Posted Yesterday, 09:49 PM

    And your algorithm for checking the check digit seems to be missing the multiplication of each digit as described in Wikipedia: http://en.wikipedia....git_calculation

    #5 babyhands ?Icon User is offline

    Reputation: 0

    • Posts: 7
    • Joined: 02-April 13

    Re: Problem with reading character 'X' from array

    Posted Yesterday, 09:59 PM

    View PostSkydiver, on 05 April 2013 - 09:49 PM, said:

    Yeah I am using an algorithm my teacher has given me, and it works for all of the ISBN's he has given me except for the ones with X's at the end. a couple of the ones he has given me are 0-89237-010-6 0-8306-3637-4, my algorithm is fine from what I have checked, I am just having problems with ISBN's with X's at the end

    #6 ccubed ?Icon User is online

    Reputation: 124

    • Posts: 1,279
    • Joined: 13-June 08

    Re: Problem with reading character 'X' from array

    Posted Yesterday, 11:57 PM

    I'm making a guess, but based on what I'm seeing, this is your problem.
    
 (isbn[i][k] >= '0' && isbn[i][k] <= '9') || (save == 10 && isbn[i][k] == 'X') 

    Problem is, when does save = 10? The only time I see you setting Save is if it passes this if statement and has an 'X'. And you have an And statement so..

    save == 10 AND isbn[i][k] == 'X'

    Except, Save will never equal 10...unless it passes this if check and gets down to the primary if isbn == x. But it won't, again, because save is never 10 at the same time the isbn is X and since X is greater than 0 but also greater than 9, it just passes the giant if statement when it hits an X and hits the elseif.

    This post has been edited by ccubed: Yesterday, 11:59 PM


    Page 1 of 1


    Source: http://www.dreamincode.net/forums/topic/317778-problem-with-reading-character-x-from-array/

    angelina jolie oscars chardon high school christopher plummer viola davis school shooting in ohio shooting at chardon high school sasha baron cohen

    Friday, April 5, 2013

    Amanda Bynes, It's Time to Get Some Help

    Amanda Bynes is having some mental and emotional troubles, and it's time that someone step up and help her. The 27-year-old has been turning to Twitter to share her problems with the world, and watching her downward spiral has become pretty upsetting.

    Source: http://www.ivillage.com/amanda-bynes-reveals-eating-disorder-twitter/1-a-532449?dst=iv%3AiVillage%3Aamanda-bynes-reveals-eating-disorder-twitter-532449

    neurofibromatosis steve jobs fbi file suge knight obama birth control mortgage settlement macauly culkin joe namath

    Updated Nexus 7 with new screen and Qualcomm CPU coming in July, says Reuters

    Nexus 7

    "Power reasons" force the switch from NVIDIA's Tegra platform to Qualcomm according to the source

    A report from Reuters earlier says that come July, we'll have a new version of Google's popular Nexus 7 tablet. ASUS will still be the manufacturer, but a few key things will have changed. Expect a higher resolution screen with smaller bezels, and concerns over "power" (we take that to mean battery power) have forced a switch to Qualcomm for the CPU.

    Pricing is said to still be in limbo, but the $199 figure has been mentioned. This is the same base price as last year's Nexus 7, and a key to its success. 

    If this rumor turns out to be true, a July release would work well with an unveiling at Google I/O this May. ASUS sold an estimated 4.6 million Nexus 7s in the second half of last year, and updated specs at the same price will draw plenty more interest. We're keeping an eye on this one.

    Source: Reuters



    Source: http://feedproxy.google.com/~r/androidcentral/~3/xl5Zusv7LYg/story01.htm

    new smyrna beach st. joseph puerto rico primary manning peyton florida state meghan mccain

    Thursday, April 4, 2013

    Arizona city becomes state's first to allow same-sex civil unions

    By Tim Gaynor

    BISBEE, Arizona (Reuters) - A former Arizona copper mining town reborn as an artists' community defied the threat of legal action on Tuesday and became the first city in the conservative southwestern state to allow civil unions between same-sex couples.

    The city council in Bisbee, a city of 5,600 residents in southeast Arizona, voted five to two to pass a measure allowing any couple to join in a civil ceremony, regardless of their sex or sexual orientation.

    "We're just acknowledging the people that live here. It's a big step in the right direction (and) for a tiny town ... it's pretty neat," Gene Conners, the first-term council member who proposed the measure said shortly after it passed.

    A city founded on a mountain of copper ore in 1902, Bisbee reinvented itself as a laid-back artists' enclave after the local Phelps Dodge mine shut in 1975.

    The Council's vote comes as the Supreme Court is weighing whether to strike down a law that denies federal benefits to legally married same-sex couples, in a move that would reflect growing support in the United States for gay marriage.

    A Reuters/Ipsos poll last month found that 55 percent of Americans surveyed said married gay and lesbian couples should be able to qualify for Social Security survivor payments and other benefits provided to married heterosexual couples.

    Arizona's constitution recognizes marriage as a union of one man and one woman. Hours before the vote, the state's attorney general, Tom Horne, wrote to the council warning it had "no authority to pass the ordinance" and that if it was approved he would seek to have it blocked in court before it could come into effect.

    "The only proper way to change a statute is through the legislature, not through actions of the city council attempting to change a state statute within its boundaries," Horne said in a statement. He did not make further comment after the vote.

    City Attorney John A. MacKinnon told the meeting late Tuesday he did not believe Horne had a "real case", adding that he believed he wanted "to make a political statement".

    CITY HALL CERTIFICATES

    The ordinance in Bisbee, which a popular local bumper sticker describes as a "liberal oasis in conservative desert," draws on language in a state civil union bill currently stalled in the Republican-controlled Arizona legislature.

    A successful legal challenge notwithstanding, the ordinance is set to come into effect in May. Couples will be able to go to City Hall and pay $76 - the cost of a marriage license at the county courthouse - for a civil union certificate.

    It will only be valid within the limits of the city, a picturesque trove of landmark buildings, galleries, coffee shops and old miners' cottages perched in the folds of the Mule Mountains overlooking Mexico.

    Benefits extended to couples include the right to visit their sick partner in the hospital, obtain a family pass for the city swimming pool, and, for city employees, the chance for their partner to buy into their benefits - rights currently denied to same-sex couples.

    At the lively council meeting late on Tuesday, two opponents expressed concerns that the measure could hurt tourism and snarl the city in costly litigation, while several others opposed it on religious grounds, calling it an "abomination".

    "As far as I know, marriage is still between a man and a woman," resident Regina Drybread told the packed meeting. She added that while the ordinance only allowed for civil unions, "in reality it's the first step to legalizing same-sex marriage".

    But other residents embraced the ordinance, among them James Cool, who said that same-sex couples were one of the last minorities to be discriminated against in the United States - although that was now changing.

    "The train in this country has left the station on civil unions, just as it did on interracial marriage and voting rights," he said. "If you don't like civil unions, don't get one," he added to cheers.

    (Reporting by Tim Gaynor; Editing by Cynthia Johnston and Pravin Char)

    Source: http://news.yahoo.com/arizona-city-becomes-states-first-allow-same-sex-072925329.html

    abraham lincoln vampire hunter their eyes were watching god lara logan manu ginobili sports illustrated swimsuit 2012 aretha franklin whitney houston paul williams

    HTC First: Pure Facebook Phone

    The HTC First is a new smartphone that's deeply integrated with Facebook Home. The 4.3-inch AT&T phone runs on a Facebook Home-optimized version of Jelly Bean and comes in four different colors. More »


    Source: http://feeds.gawker.com/~r/gizmodo/full/~3/5zz85QHQnHg/htc-first-pure-facebook-phone

    petrino fired george zimmerman charged big sean sherri shepherd sherri shepherd arkansas razorbacks trisomy 18

    Wednesday, April 3, 2013

    ASUS teases Transformer Pad Infinity Android 4.2 update today

    Android 4.2 for TF700

    TF700 to join its little brother on the latest version of Android

    The ASUS Transformer Pad 300 was the first non-Nexus device to get Android 4.2 just a month ago, and now its larger cousin the Transformer Pad Infinity (TF700) is set to join on the latest version of Jelly Bean. An image posted to the official ASUS Facebook page reveals that the update should be landing today -- though there's no mention of which territories will be included in this initial roll-out.

    If the Infinity's 4.2 update is anything like that of the TF300, owners can expect updates for ASUS's App Locker, Virtual Keyboard, Lock Screen and Setup Wizard applications alongside the new OS.

    Transformer Pad Infinity owners, hit the comments and let us know if you're seeing the update on your device yet.

    Source: ASUS on Facebook



    Source: http://feedproxy.google.com/~r/androidcentral/~3/FADqhK-a4UA/story01.htm

    social darwinism wisconsin recall election april 4 santa monica college wisconsin primary dallas fort worth airport texas tornados

    Why was March so cold? Blame Greenland.

    You're not imagining it: March 2013 was chilly ? the second-coldest March since 2000. The culprit is a stubborn mass of warm air over Greenland that blocked the jet stream.

    By Douglas Main,?Our Amazing Planet / April 2, 2013

    This NOAA satellite image taken March 28 shows the stationary air mass over Greenland and the North Atlantic that kept March so chilly for most of the continental US.

    Weather Underground / AP

    Enlarge

    Although spring has arrived, it may not feel that way for many in the United States and Canada who have had to put up with unusually cold temperatures.

    Skip to next paragraph

    ' + google_ads[0].line2 + '
    ' + google_ads[0].line3 + '

    '; } else if (google_ads.length > 1) { ad_unit += ''; } } document.getElementById("ad_unit").innerHTML += ad_unit; google_adnum += google_ads.length; return; } var google_adnum = 0; google_ad_client = "pub-6743622525202572"; google_ad_output = 'js'; google_max_num_ads = '1'; google_feedback = "on"; google_ad_type = "text"; google_adtest = "on"; google_image_size = '230x105'; google_skip = '0'; // -->

    Last month was a chilly one, ranking as the second-coldest March in the continental United States since 2000, according to the National Weather Service (NWS). The average temperature across the United States this March was also 13 degrees Fahrenheit (7.2 degrees Celsius) lower than in March 2012, and a late-winter blizzard broke snowfall records in many areas.

    So, why has it been so cold?

    The culprit is a stubborn, stationary mass of warm air over Greenland and the North Atlantic that has blocked the normal flow of air from west to east and south to north, said Greg Carbin, a meteorologist with the NWS' Storm Prediction Center. This flow of air, known as the jet stream, usually brings more warm air from the South as the Northern Hemisphere begins to heat up in the spring.

    Obstinate air masses

    This March, however, the mass of warm air ? a high-pressure system that repels incoming weather systems ? has redirected air currents and created a pattern of winds coming from the Northwest, blasting the eastern two-thirds of the United States with Arctic air, Carbin said.

    "This obstinate mass of warm air over Greenland has redirected air currents like a rock in a stream," Carbin said.

    However, the spring season hasn't been cold everywhere. In fact, the southwestern United States has been warmer than average, as the region has been unaffected by the blocking system in the North Atlantic, said Bob Henson, a meteorologist and science writer with the University Corporation for Atmospheric Research in Boulder, Colo.

    Due, in part, to the cold, there have been fewer than 20 tornadoes in the United States this March, Carbin said. On average, March will see 76 twisters across the United States. Tornadoes depend on warm, moist air, which was scarce this past March, Carbin added.?

    Climate change?

    Some research has suggested a link between a retreat of Arctic sea ice in a warming world and these high-pressure blocking systems, Carbin said.

    Source: http://rss.csmonitor.com/~r/feeds/science/~3/HgNeTN30RiQ/Why-was-March-so-cold-Blame-Greenland

    Super Bowl Ads 2013 Buffalo Wild Wings Superbowl Start Time Jim Harbaugh Who Won The Superbowl Super Bowl Halftime Show 2013 Super Bowl Commercials 2013