Welcome, Guest. Please Login or Register.
Apr 20th, 2024, 4:53am

Home Home Help Help Search Search Members Members Login Login Register Register
Arimaa Forum « My hobby »


   Arimaa Forum
   Arimaa
   Off Topic Discussion
(Moderators: christianF, supersamu)
   My hobby
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: My hobby  (Read 2430 times)
hanzack
Forum Senior Member
****




lalala...I'm singing a song of arimaa.

   


Gender: male
Posts: 35
My hobby
« on: Jun 19th, 2010, 7:24am »
Quote Quote Modify Modify

I want a program to plot all leap years from 1800 to 2007,
 
and add an indentation everytime it plot 10 leap years.
 
like this---->
 
1804 1808 1812 1816 1820 1824 1828 1832 1836 1840
1844 1848 1852 1856 1860 1864 1868 1872 1876 1880
1884 1888 1892 1896 1904 1908 1912 1916 1920 1924
1928 1932 1936 1940 1944 1948 1952 1956 1960 1964
1968 1972 1976 1980 1984 1988 1992 1996 2000 2004
 
 
I wrote like this--->
 
 
#include <stdio.h>
int main()
{  
   int x;
  for(x = 1800; x <= 2007; x++){
   if(x % 4 == 0){
    if(x % 100 == 0){
     if(x % 400 == 0){
 printf("%d ", x);
 if((x - 1800) % 10 == 0){
  printf("\n");}else{}
     }else{}
    }else{
    printf("%d ", x);
     if((x - 1800) % 10 == 0){
  printf("\n");}else{}
    }else{}}
    return 0;
}
 
 
I'm not sure that's like it, because I don't know how to use linux? centos?.
 
Please help me~~  Huh
 
This is not my homework, so no need to hold back Kiss
IP Logged
FireBorn
Forum Guru
*****



Arimaa player #1832

   


Gender: male
Posts: 123
Re: My hobby
« Reply #1 on: Jun 19th, 2010, 10:08am »
Quote Quote Modify Modify

By indentation, do you mean new line?
 
Also, you can use [ code ] tags to make it format correctly (the # button).
 
Get rid of the "else {}" things. They are unnecessary.
 
What output are you getting right now?
IP Logged
hanzack
Forum Senior Member
****




lalala...I'm singing a song of arimaa.

   


Gender: male
Posts: 35
Re: My hobby
« Reply #2 on: Jun 19th, 2010, 3:58pm »
Quote Quote Modify Modify

yes i meant new lines. I didn't know the expression.
 
and I can't use linux at home so I don't know what output I get Undecided
 
I want to use both windows xp and linux on my computer but don't know how to do it.
 
and once I download linux, I'm afraid I may not be able to use windows xp anymore Roll Eyes
IP Logged
FireBorn
Forum Guru
*****



Arimaa player #1832

   


Gender: male
Posts: 123
Re: My hobby
« Reply #3 on: Jun 19th, 2010, 4:16pm »
Quote Quote Modify Modify

There are C++ compilers for Windows. I believe Visual Studio Express is free. http://www.thefreecountry.com/compilers/cpp.shtml
 
I think in order to use linux and windows dualboot you'll have to reformat the drive first. Unless you have another one, maybe. I'm not sure of the details either.
IP Logged
hanzack
Forum Senior Member
****




lalala...I'm singing a song of arimaa.

   


Gender: male
Posts: 35
Re: My hobby
« Reply #4 on: Jun 19th, 2010, 10:15pm »
Quote Quote Modify Modify

Thank you FireBorn!
 
I got this--->
 
1804 1808 1812 1816 1820  
1824 1828 1832 1836 1840  
1844 1848 1852 1856 1860  
1864 1868 1872 1876 1880  
1884 1888 1892 1896 1904 1908 1912 1916 1920
1924 1928 1932 1936 1940
1944 1948 1952 1956 1960  
1964 1968 1972 1976 1980
1984 1988 1992 1996 2000
2004  
 
How come Huh Cry
 
 
please tell me how to make a new line evrytime it plots 10 leap years
« Last Edit: Jun 19th, 2010, 10:26pm by hanzack » IP Logged
Oystein
Forum Full Member
***



Arimaa player #3272

   


Gender: male
Posts: 21
Re: My hobby
« Reply #5 on: Jun 20th, 2010, 2:46am »
Quote Quote Modify Modify

Make a counter for the number of years that has been plotted. Then use this counter instead of the year to check if you should add a new line.
IP Logged
hanzack
Forum Senior Member
****




lalala...I'm singing a song of arimaa.

   


Gender: male
Posts: 35
Re: My hobby
« Reply #6 on: Jun 20th, 2010, 8:37pm »
Quote Quote Modify Modify

I wrote like this--->
 
#include <stdio.h>  
int main()  
{  
   int x, y = 0;  
  for(x = 1800; x <= 2007; x++){  
   if(x % 4 == 0 && ((x % 100) != 0 || x % 400 == 0))
    printf("%d ", x);y++;
  if(y % 10 == 0){
   printf("\n");}}
    return 0;  
}  
 
 
and got this--->
 
1804 1808
1812 1816
1820 1824 1828
1832 1836
1840 1844 1848
1852 1856
1860 1864 1868
1872 1876
1880 1884 1888
1892 1896
1904 1908
1912 1916
1920 1924 1928
1932 1936
1940 1944 1948
1952 1956
1960 1964 1968
1972 1976
1980 1984 1988
1992 1996
2000 2004
 
My pc hates me! help meee! awawawa Sad
IP Logged
hanzack
Forum Senior Member
****




lalala...I'm singing a song of arimaa.

   


Gender: male
Posts: 35
Re: My hobby
« Reply #7 on: Jun 20th, 2010, 9:01pm »
Quote Quote Modify Modify

Thank you very much!  
I made it!
 Kiss
IP Logged
knarl
Forum Guru
*****



Arimaa player #1648

   


Gender: male
Posts: 104
Re: My hobby
« Reply #8 on: Jun 20th, 2010, 9:37pm »
Quote Quote Modify Modify

The problem is you were printing a new line after every leap year where a multiple of 10 years had elapsed since 1800, and as correctly mentioned earlier in this thread, you could index the number of leap years with a separate variable.
 
Here's some reformatted, corrected code:
 
#include <stdio.h>
int main()
{
 int x,leap=0;
 
 for(x = 1800; x <= 2007; x++)
 {
  if((x%4 == 0) && ((x%100 != 0)||(x%400 == 0)))
  {
   leap++;
   if(leap%10 == 0)
   {
    printf("%d \n", x);
   }
   else
   {
    printf("%d ", x);
   }
  }
 }
    return 0;
}
IP Logged
knarl
Forum Guru
*****



Arimaa player #1648

   


Gender: male
Posts: 104
Re: My hobby
« Reply #9 on: Jun 20th, 2010, 9:46pm »
Quote Quote Modify Modify

By the way. I use a nice free C/C++ development environment for windows (cross platform) called dev C++ by bloodshed http://www.bloodshed.net/
 
It's licence is GNU.
 
Cheers,
knarl.
IP Logged
Polyfractal
Forum Senior Member
****



Arimaa player #3241

   


Gender: male
Posts: 27
Re: My hobby
« Reply #10 on: Jun 21st, 2010, 6:10am »
Quote Quote Modify Modify

I believe Visual Studio Express is free too, if you want to use a Microsoft product. Smiley
IP Logged
hanzack
Forum Senior Member
****




lalala...I'm singing a song of arimaa.

   


Gender: male
Posts: 35
Re: My hobby
« Reply #11 on: Jun 22nd, 2010, 12:04am »
Quote Quote Modify Modify

Thank you very much knarl Polyfractal!!!
 
The information is ultra hyper helpful to me.
 
I'm very happy ,so I have no choice but dance!
 
   &#9834;&#9834;&#12541;(&#969;&#12539;&#12541;)(&#12494;&#12539;&#969;)&# 65417;&#9834;&#9834;
 
 Cheesy
IP Logged
Arimabuff
Forum Guru
*****



Arimaa player #2764

   


Gender: male
Posts: 589
Re: My hobby
« Reply #12 on: Jun 22nd, 2010, 7:40am »
Quote Quote Modify Modify

on Jun 22nd, 2010, 12:04am, hanzack wrote:
Thank you very much knarl Polyfractal!!!
 
The information is ultra hyper helpful to me.
 
I'm very happy ,so I have no choice but dance!
 
   &#9834;&#9834;&#12541;(&#969;&#12539;&#12541;)(&#12494;&#12539;&#969;)&# 65417;&#9834;&#9834;
 
 Cheesy

I think that's Japanese for "I don't have that font".
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Arimaa Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.