using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class A{
static void Main(string[] args)
{
string s = Console.ReadLine();
int j = 0;
while (j<5)
{
if (s[j] >= '0' && s[j] <= '9')
{
j++;
}
else break;
}
Console.WriteLine("位数:{0}",j);
for (int i = 0; i < j; i++)
{
Console.Write("{0} ",s[i]);//输出
}
Console.ReadKey();
}
}
用C#编写程序,输入一个不多于5位的正整数,要求:(1)输出它是几位数(2...
static void Main(string[] args){ string s = Console.ReadLine();int j = 0;while (j<5){ if (s[j] >= '0' && s[j] <= '9'){ j++;} else break;} Console.WriteLine("位数:{0}",j);for (int i = 0; i < j; i++){ Console.Write("{0} ",s[i]);\/\/输出 ...
用C#怎样编写从键盘输入一个正整数,按数字的相反顺序输出的程序_百度知 ...
static void Main(string[] args){ String num = Console.ReadLine();int length = num.Length;for (int i = length-1; i >=0;i-- ){ Console.Write(num[i]);} Console.ReadLine();}
c语言,任意输入一个五位正整数,逆序输出每一位上的数
include <stdio.h>void main(){int i,n,a[5];scanf("%d",&n);for(i=0;i<5;i++){a[i]=n%10;n=n\/10;}for(i=0;i<5;i++)if(a[i]){for(;i<5;i++)printf("%1d",a[i]);break;}}运行示例:
输入一个4位数的正整数,用C#编写程序,输出这个数的千位、百位、十位...
static void Main(string[] args){Console.WriteLine("请输入一个4位的正整数:");string input = Console.ReadLine();while (input.Length != 4){Console.WriteLine("请输入一个4位的正整数:");input = Console.ReadLine();}Console.WriteLine("你输入的数是{0},它的千位是{1},百位是{2...
用C#怎么做“从键盘输入一个正整数,按数字的相反顺序输出。”
string n = Console.ReadLine();string _n;try { int.Parse(n);for (int i = 1; i <= n.Length; i++){ _n += n[n.Length - i];} Console.WriteLine(_n);} catch (Exception ex){ MessageBox.Show(ex.Message);}
C#编程:输入一个4位数的正整数,编写程序,输出这个数的千位,百位,十位...
= 4 int xxx = Mat % 1000 \/ 100; 例如 4321 % 1000 = 321 321 \/ 100 = 3 int xx = Mat % 100 \/ 10; 例如 4321 % 100 = 21 21 \/ 10 = 2 int x = Mat % 10; 例如 4321 % 10 = 1 DOS那种页面的话,要先获取你输入的数字。也就是要先Consolute.Read()一下。
编写一个程序,输入一个正整数,并做以下运算:如果为偶数,除以2,如果为...
5 I have seen one, although the consequences not so serious, when the groom is anxious, Aoao turned to scold the two go under the bride's family on the NB, the meal for mercy, then who can not stand that scene. That nauseating point, my buddy that his wife love to a ...
编写一个C#控制台应用程序,对于输入的正整数n,计算1!+2!+3!+…+n...
用递归,这类题很好算啊 using System;class test { public static void Main(){ int n=Convert.ToInt32(Console.ReadLine());Console.Write(jiejia(n).ToString());} public static int jiecheng(int n){ return n>1?n*jiecheng(n-1):1;} public static int jiejia(int n){ return n>1...
c# 输入五个数 分别输出其中的最大值和最小值
第一种方法:static void Main(){ Console.WriteLine("请输入5个数字,数字之间用空格分隔:"); string input=Console.ReadLine(); string [] arrTemp = input.Split(new char[]{' '}).ToArray(); decimal [] arr = Array.ConvertAll<string, decimal>(arrTemp, s => Convert...
用C语言编程从键盘输入一个正整数,判断其个位数是否为5,若是5则输出...
int number;printf("请输入一个正整数: ");scanf("%d", &number);\/\/ 确保输入的是正整数 if (number <= 0) { printf("输入错误,请输入一个正整数。\\n");return 1; \/\/ 返回非零值表示程序出错 } \/\/ 获取个位数 int last_digit = number % 10;\/\/ 判断个位数是否为5 if (last_...