FizzBuzz

Stato
Discussione chiusa ad ulteriori risposte.
ShuraBozz ha detto:
no perchè è uguale a quello di lepa!

E ti giuro che non l'ho neanche guardato il suo xD
Forse dovevo farlo in C, così non si creavano ambiguità xD
 
Oh.. vabè, che vuoi vendertelo il codice?

Se qualcuno ha altre idee su come svilupparlo (o inerenti al topic in questione) bene..
C# 3.0
Codice:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

namespace asd
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList a = new ArrayList();
            ArrayList _out = new ArrayList();

            for (int i = 1; i <= 100; i++)
            {
                a.Add(i);
                _out.Add(i);
            }

            var t = from c in a.Cast<int>() where c % 3 == 0 && c % 5 != 0 select new { Number = c, Out = "Fizz" };
            var tt = from cc in a.Cast<int>() where cc % 5 == 0 && cc % 3 != 0 select new { Number = cc, Out = "Buzz" };
            var ttt = from ccc in a.Cast<int>() where ccc % 5 == 0 && ccc % 3 == 0 select new { Number = ccc, Out = "FizzBuzz" };

            foreach (var O in t)
               _out[_out.IndexOf(O.Number)] = O.Out;

            foreach(var O in tt)
               _out[_out.IndexOf(O.Number)] = O.Out;

            foreach (var O in ttt)
                _out[_out.IndexOf(O.Number)] = O.Out;

            foreach (var oo in _out)
                Console.WriteLine(oo);

            Console.ReadKey();
        }
    }
}
Questo è un altro modo per svilupparlo.
 
ShuraBozz ha detto:
embè è identitico è più di un'ambiguità, non so che dirti

-.- Come penserai che io rippi... per di più un esercizio... Comunque eccotelo anche in Python, così sei contento:
Codice:
#!/usr/bin/python
for i in xrange(1,101):
  while(i%3==0):
      print "Fizz"
      break
  while(i%5==0):
      print "Buzz"
      break
  while(i%3!=0 and i%5!=0):
    print i
    break
Non vedo versioni in Python, quindi...
 
è la prima volta che posto un codice..che ne pensate? è un C semplice semplice
PHP:
#include <stdio.h>
#include <conio.h>

main(){
       int i=1;
       while (i<=100){
                                while ((i%3!=0)||(i%5!=0)){
                                            printf("%d\n",i);
                                            i=i+1;
                                            break;
                                            }
                                while ((i%3==0)&&(i%5==0)){
                                            printf("FizzBuzz\n");
                                            i=i+1; 
                                            
                                            break;
                                            }
                                while (i%3==0){
                                            printf("Fizz\n");
                                            
                                            i=i+1;
                                            break;
                                            }
                                while (i%5==0){
                                            printf("Buzz\n");
                                            i=i+1;
                                            break;
                                            }
                                }
       getch();
       }
 
Stato
Discussione chiusa ad ulteriori risposte.