package main
import "fmt"
func main() {
n := 15
for i:=1; i<=n; i++ {
if (i%3 == 0) && (i%5 == 0) {
fmt.Println("FizzBuzz")
} else if i%3 == 0 {
fmt.Println("Fizz")
} else if i%5 == 0 {
fmt.Println("Buzz")
} else {
fmt.Println(i)
}
}
}
java 编写一个从用户读取10个数字的java程序,并在列表中打印第一个奇数。
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package BASICJAVA;
import java.util.Scanner;
/**
*
* @author ABIR
*/
public class Array_If_Break_Exit {
public static void main(String[]args){
Scanner abir =new Scanner(System.in);
int[] number=new int[10];
for (int i = 0; i < number.length; i++) {
System.out.println("Enter your "+(i+1)+" number");
number[i]=abir.nextInt();
}
for (int i = 0; i < number.length; i++) {
if (number[i]%2!=0) {
System.out.println("your first odd number is "+ number[i]);
break;
}
}
}
}