輸入一字串,將其反著輸出,如輸入abc,則輸出cba。
程式碼實現:
#include <iostream.h>
#include <stdio.h>
#include <string.h>
int main()
{
char buffer[32];
char str[32];
cout<<"請輸入一個數:"<<endl;
cin>>buffer;
int len=0;
len=strlen(buffer);
cout<<"長度為"<<len<<endl;
for(int i=0;i<len;i++)
{
str[i]=buffer[len-i-1];
}
str[len]='/0';
cout<<str;
return 0;
}
相關推薦
輸入一字串,將其反著輸出,如輸入abc,則輸出cba。
程式碼實現: #include <iostream.h>#include <stdio.h>#include <string.h>int main(){ char buffer[32]; char str[32]; cout<<
讓使用者輸入一個日期字串,將其轉換成日期格式, 格式是(yyyy/MM/dd,yyyyMMdd,yyyy-MM-dd)中的一種, 任何一種轉換成功都可以; 如果所有的都無法轉換,輸出日期格式非法。
第三種方法 while(true) { Date d; System.out.println("正在
java--建立一個帶預設構造方法(即無參構造)的類,在構造方法中列印一條訊息"Hello Constructor";再為這個類新增一個過載構造方法,令其接收一個字串引數,將其一起打印出來
題目描述:建立一個帶預設構造方法(即無參構造)的類,在構造方法中列印一條訊息"Hello Constructor";再為這個類新增一個過載構造方法,令其接收一個字串引數,並在這個有參構造方法中把"Hello Constructor"和接收的引數一起打印出來。 //Person類 class Pe
java--建立一個帶預設構造方法(即無參構造)的類,在構造方法中列印一條訊息"Hello Constructor";再為這個類新增一個過載構造方法,令其接收一個字串引數,將其一起打印出來
題目描述:建立一個帶預設構造方法(即無參構造)的類,在構造方法中列印一條訊息"Hello Constructor";再為這個類新增一個過載構造方法,令其接收一個字串引數,並在這個有參構造方法中把"Hello Constructor"和接收的引數一起打印出來。 //Perso
輸入一個數n,將其反轉輸出。
要求輸出時不含前導0 如輸入365,輸出563. 輸入520,輸出25. #include<iostream> using namespace std; int main() { int n; cin>>n; int t; while(
輸入一個數,將其轉化為二進位制輸出
解題思路: 十進位制轉二進位制方法,對2求餘,最後將餘數逆序輸出 #include<stdio.h> int main() { int num,a[20],i=0; printf("Input a number:");
c++入門:輸入一個字串,將其分段輸出,分段符為除字母和數字之外的符號。
輸出 輸入一個字串 樣例輸入 ad/adfa,123d?a1 樣例輸出 ad adfa 123d a1#include<iostream> #include<string.h>
c語言從鍵盤中輸入一串字串,將字元中的大寫轉化成小寫字母,將小寫字母轉換成大寫字母,以*號鍵結束
#include <stdio.h> int main(int argc, const char * argv[]) { char c; c=getchar(); while (c!='*') { if(c
C++輸入一個字串,將其逆序輸出
方法一: #include<iostream> #include<string> using namespace std; void main() { char a[50]; cin>>a; char *rev=strrev(a);
Java 輸入一個正整數,將其用中文打印出來
輸入一個正整數,將其用中文打印出來。使用java 實現 import java.util.Scanner; public static void main(String[] arge){
輸入一串字元,將其中的大寫變成小寫,若不為大寫則原樣輸出
方法一 import java.util.Scanner; public class Main { public static void main(String[] args) {
輸入一個8位二進位制數,將其轉化為十進位制數輸出
#include<iostream> using namespace std; double power(double x,int n) { double val=1.0; while(n--) val*=x; return val; } int main(
編寫一個程式,實現從命令列引數輸入一字串,統計該字串中字元輸入字元的出現的次數。
package pro1214test; import java.util.Scanner; public class eCiShu { public static void main(String[] args) { Scanner s = new Scanner(System.
輸入兩個整數n和m,從數列1,2,3,...,n中隨意取幾個數,使其和等於m,將其所有可能的組合列出來。 遞迴求解
/* *[email protected] 轉載請註明出處 *問題:輸入兩個整數n和m,從數列1,2,3,...,n中隨意取幾個數, *使其和等於m,將其所有可能的組合列出來。 *求解思路:(遞迴求解) *(1)如果n>m則數列中>m的部分不可能參與組
輸入一個int型整數,將其逆序輸出,每個數字後有一個空格。 將n按其逆序輸出,每個數字後有一個空格,輸出佔一行。例如,輸入12354,輸出4 5 3 2 1
#include<stdio.h>#include<math.h> int main(){ int n,a; scanf("%d",&n); while(1) { if(n>=10) { a=n%10; n=n/10; print
鍵盤輸入字串並將其轉為字元陣列
import java.util.Scanner; public class MoveCode { public static void main(String[] args) { // TODO Auto-generated me
組合語言學習之路(7)------------輸入10進位制數,將其轉換為2進位制數,存放在ax中,再將其轉換為ASCII碼並輸出
data segment inf1 db "please input a number(1-361):$" ibuf db 7,0,6 dup(0) obuf db 6 dup(0) data ends c
輸入一個整數,將其反向輸出,如輸入12345,要求輸出54321
#include "iostream.h"int OutNum(int temp){ int now=0,output=0; while(temp>9) { now=temp%10; temp=(temp-now)/10;
輸入一個100以內的正整數,將其分解質因數後輸出
思路: 將一百以內的素數建成一個列表 輸入數後向陣列中查詢 如果不在陣列中,就從列表中最小的素數開始,找到能被該數整除得數 將得到的數進行步驟23,知道滿足條件一 import math prime=[] factor=[] def is_Prime(n): fo
對uuid的處理,將其字串轉化為大寫並無空格
寫這個程式之前需要知道UUID,UUID是全球唯一標識碼,所以保證了數字的唯一性。安裝uuid工具鏈:sudo apt-get install uuid-devuuid提供的API:void uuid_generate(uuid_tout);void uuid_generat