rjps.net
当前位置:首页 >> VB的编程 输入任意的一个正整数 要把它逆序输出 >>

VB的编程 输入任意的一个正整数 要把它逆序输出

最简单的方法:MsgBox StrReverse(InputBox("请输入一个正整数:")) 符合你题意的方法:Dim s1 As String, s2 As String, i As Integer s1 = InputBox("请输入一个正整数:") For i = Len(s1) To 1 Step -1 s2 = s2 & Mid(s1, i, 1) Next MsgBox s2

Private Sub Command1_Click() Dim s1 As String Dim n As Long Dim i As Integer n = InputBox("请输入N的值") s1 = Str(n) For i = Len(s1) To 1 Step -1 Print Mid(s1, i, 1); Next i End Sub

设这个数是numint data[10];int count = 0;do{data[count++] = num%10;num/= 10;}while(num!=0);int i;for(i = count - 1;i >= 0;i++){printf("%d ",data[i]);}

a=inputbox("")for i = len(a) to 1 step -1s=s & mid(a,i,1)nextmsgbox s

#include "stdio.h" int main() { int num,temp,i=0; printf("请输入一个数字:"); scanf("%d",&num); while(num>0) { temp=num%10; ++i; printf("%d",temp); num=num/10; } printf("\n这个数是%d位数",i); return 0; }

Private Sub Form_Load() Dim i As Integer Dim temp As Integer Dim result As String Randomize For i = 1 To 3 temp = Rnd * 10 If temp = 10 Then temp = 1 result = result & Trim(Str(temp)) Next Print "随机数:" & result Print "反转后:" & StrReverse(result) End Sub

dim i as integerdim g,s,bi=text1.textg=i mod 10s=(i mod 100)\10b=i \ 100text2.text= g & s & b

Private Sub Form_Click()Dim a%, q%, b%, s%, g%a = Val(InputBox("请输入一个四位数", "输入"))q = a \ 1000b = (a - q * 1000) \ 100s = (a - q * 1000 - b * 100) \ 10g = a - q * 1000 - b * 100 - s * 10Print "你输入的数为:" & aPrint "倒序后为:" & g & s & b & qEnd Sub

把这个整数当字符串输入存入数组,再逆序输出就可以了#include<stdio.h>#include<string.h>main(){char a[100];int i,long; gets(a);long=strlen(a);for(i=long-1;i>=0;i--) printf("%c",a[1]);printf("\n");}

#include <stdio.h>#include <conio.h> int main(void) { int n; printf("请输入一个整数: "); scanf("%d", &n); printf("逆序输出: "); while (n > 0) { printf("%d", n % 10); n /= 10; } printf("\n"); getch(); return 0; }

网站首页 | 网站地图
All rights reserved Powered by www.rjps.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com