哈工大機考:數組逆置
題目描述
輸入一個字符串,長度小於等於200,然後將數組逆置輸出。輸入描述:
測試數據有多組,每組輸入一個字符串。
輸出描述:
對於每組輸入,請輸出逆置後的結果。
輸入例子:
hdssg
輸出例子:
gssdh
代碼:
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int main(){ char a[210]; while(gets(a)){ for(int i=strlen(a)-1;i>=0;i--){ cout<<a[i]; } cout<<endl; } return 0; }
哈工大機考:數組逆置
相關推薦
哈工大機考:數組逆置
end std gin () 數據 log ostream margin 哈工大 時間限制:1秒 空間限制:32768K 題目描述 輸入一個字符串,長度小於等於200,然後將數組逆置輸出。 輸入描述: 測試數據有多組,每組輸入一個字符串。 輸出描述: 對於每組輸入,
哈工大機考:求最大值
style 回車 iostream 題目 cin 輸入 class mes 空間 時間限制:1秒 空間限制:32768K 題目描述 輸入10個整數,要求輸出其中的最大值。 輸入描述: 測試數據有多組,每組10個整數。 輸出描述: 對於每組輸入,請輸出其最大值(有回車
用異或操作實現的交換函數用以實現數組逆置中須要註意的問題
span include style 試題 blog text fontsize lib mod 用元素交換函數實現數組逆置非常easy,如以下代碼:(數組左右元素交換) #include<iostream> #include<stdlib.h>
codeup1967 數組逆置
algorithm etl 翻轉 ostream ace line get include logs //基本都是多組數據測試,所以不要寫一組數據的代碼格式!!!//全排列next_permutation()函數還真得用do{}while()循環格式來寫;#include
數組逆置
交換 std int tdi spa fun hit turn ace #include<stdio.h>void fun(int a[], int n){int i,j,temp;for(i = 0,j = n-1; i < j; i ++,j --){
指針入門,以及利用指針簡單的數組逆置
pre emp 內存 def for ++ tdi pan 簡單 #include <stdio.h> #include <stdlib.h> #define N 6 int main() { int nums[N]={20
學習筆記:javascript內置對象:數組對象
b- sort splice 刪除 分隔 href 結果 join() strong 1.數組對象的創建 1.設置一個長度為0的數組 var myarr=new array(); 2.設置一個長度為n的數組 var myarr=new arr(n); 3.聲明一個
劍指offer(1):數組
abs views 二維數組 如同 pad enter 數組與指針 在線 c語言細節 1 寫作計劃 最近在看《劍指offer》,發現自己有很多的數據結構與算法的基礎知識要復習,《好書一起讀(131):讓寫作更好》中提到用寫作倒逼閱讀,我很是贊同。所以,計劃以《劍指offe
面試題9:數組堆化、堆的插入、堆的刪除、堆排序
art 面試 rewind 刪除 test from minimum 面試題 排序 參考:白話經典算法系列之七 堆與堆排序 1 #include <iostream> 2 #include <climits> 3 #include <v
C++ Primer高速入門之六:數組和指針
borde ott 1.5 del word ans 12px 關聯 bre 更新:勘誤,delete [] 豬 我們知道,C語言以及早期的面向結構的語言差點兒都支持數組定義。比方整形數組int 女神[2]。表示有倆數: 女神[0], 女神[1]。她們都是
hdu2838Cow Sorting(樹狀數組+逆序數)
至少 http 個數 範圍 打開 main tdi def esp 題目鏈接:點擊打開鏈接 題意描寫敘述:給定一個長度為100000的數組,每一個元素範圍在1~100000,且互不同樣,交換當中的隨意兩個數須要花費的代價為兩個數之和。問怎樣交換使數組有序。花費的代價最小
C語言事實上不簡單:數組與指針
本質 而不是 getchar() alt 由於 == sizeof 不同 來看 之前在寫C的時候,沒怎麽留意數組。就這麽定義一個。然後顛來倒去的使用即可了。只是後來碰到了點問題。解決後決定寫這麽一篇博客,數組離不開指針。索性就放一起好了。 如今我定義了一個數組:i
表示集合的數據結構:數組(Array),對象(Object),Map和Set
數據類型 過濾 .get 初始化 array 一維數組 類型 defined 初始 Map和Set是ES6標準新增的數據類型 Map: 是一組鍵值對的結構,使用一個二維數組來初始化Map,例如: var m = new Map([[‘xiaohong‘,100],[‘xia
嵌入式C語言難點一:數組
數組 位置 scanf 列表 輸出結果 clu sort 難點 can 1.數組的定義 由若幹相同類型並且有順序關系的數組組成,數組中的每個變量就叫做這個數組的元素。 表達式:<儲存類型> <數據類型> <數組名> [<常量
前端C#基礎:數組與集合
聲明 末尾 固定 相關 號稱 讀取數組 gif 不變 組類型 學習web前端是一個帶有一點小樂趣的過程。它是與理科思維比較相關聯的,所以學習好他就必須掌握牢固的基礎,對基礎知識的細節要了解。下面我就總結兩個我們經常用到,但又因為他們定義與用法都比較相近,而經常搞
BZOJ4989 [Usaco2017 Feb]Why Did the Cow Cross the Road 樹狀數組 逆序對
def void math 之間 題解 統計 排列 problem 傳送門 歡迎訪問~原文出處——博客園-zhouzhendong 去博客園看該題解 題目傳送門 - BZOJ4989 題意概括 一條馬路的兩邊分別對應的序列A、B,長度為n,兩序列為1到n的全排列。當
劍指offer:數組中出現次數超過一半的數字
一次 相同元素 log 由於 個數字 csdn tail 第一個 可能 http://blog.csdn.net/qq_27703417/article/details/70948850 數組中有一個數字出現的次數超過數組長度的一半,請找出這個數字。例如輸入一個長度為9
《Java從入門到放棄》JavaSE篇:數組
java 數組 數組,就是一組數!!!之前我們學習的變量只能保存一個數據,如果一個部門有50個員工的姓名要保存,怎麽辦?如果定義50個變量··················String name1;String name2;............String name49;String name5
數組轉置
完成 for 長度 一個數 改變 stat 數組轉置 頭部 方法 首尾交換 思路一:開辟一個等長的數組,原始數組反轉存入 public static int[] reverse(int arr[]) { { int temp = new int[arr.le
HTML-JS 數組 內置對象
== 一份 稀疏數組 map() 屬於 nsh reac 稀疏 有序 【JS中的數組】 1、數組的基本概念? 數組是在內存空間中連續存儲的一組有序數據的集合 元素在數組中的順序,稱為下標。可以使用下標訪問數組的每個元素 2、如何聲明一個數組