1.半徑為5的圓
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int r = 5;
double pi = 3.14;
double total1 = pi * r * r;
double total2 = pi * 2 * r;
Console.WriteLine("面積是{0},周長是{1}", total1, total2);
Console.ReadKey();
}
}
}
2.語數(shù)英成績
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("請輸入你的姓名");
string name=Console.ReadLine();
Console.WriteLine("請輸入你的語文成績");
string str_Chinese = Console.ReadLine();
double chinese = Convert.ToDouble(str_Chinese);
Console.WriteLine("請輸入你的數(shù)學(xué)成績");
string str_Math= Console.ReadLine();
double math = Convert.ToDouble(str_Math);
Console.WriteLine("請輸入你的英語成績");
string str_English = Console.ReadLine();
double english = Convert.ToDouble(str_English);
int Chinese = Convert.ToInt32(str_Chinese);
int Math = Convert.ToInt32(str_Math);
int English = Convert.ToInt32(str_English);
//總分
int total = Chinese + Math + English;
//平均分
double avg = total / 3.0;
Console.WriteLine("總共應(yīng)付:{0},平均分是:{1}", total,avg);
Console.ReadKey();
}
}
}