java起源英文_Abbreviation 英文詞組縮寫(來源:南陽理工大學ACM)java

As we know, we often use a short sequence of characters in place of some words with a very long name. For example, ACM is an abbreviation of “Association for Computing Machinery”. Now we are using an acronymic method to get the abbreviation. An acronym is generated from a long name by capitalizing the first letter of every word in the name and concatenating them together. There is an exception: some words are ignored when generating the abbreviation. These words( case insensitive) meet the following rules:

1. The common words “and”, “for”, and “the”.

2. The words with length less than 3, such as “a”, “of”, “to”. Your job is to get the abbreviation of a given string by using the acronymic method.

輸入

Input starts with an integer T (T <= 100), denoting the number of test cases. Each case contains a line with several words seperated by space(s). The length of each line is less than 100. And you can assume that there is at least one available word for each case.

輸出

For each case, print the abbreviation of the word.

樣例輸入

5

Online Judge

Association for Computer Machinery

Institute of Electrical and Electronics Engineers

The Lord of the Rings

netease

樣例輸出

OJ

ACM

IEEE

LR

N

import java.util.Scanner;

/**

*

* @author admin

*As we know, we often use a short sequence of characters in place of some words with

*a very long name. For example, ACM is an abbreviation of “Association for Computing

*Machinery”. Now we are using an acronymic method to get the abbreviation. An acronym

*is generated from a long name by capitalizing the first letter of every word in the

*name and concatenating them together. There is an exception: some words are ignored

*when generating the abbreviation. These words( case insensitive) meet the following rules:

*

*1. The common words “and”, “for”, and “the”.

*

*2. The words with length less than 3, such as “a”, “of”, “to”.

*Your job is to get the abbreviation of a given string by using the acronymic method.

*

*輸入

*Input starts with an integer T (T <= 100), denoting the number of test cases.

*Each case contains a line with several words seperated by space(s). The length

*of each line is less than 100. And you can assume that there is at least one

*available word for each case.

*輸出

*For each case, print the abbreviation of the word.

*實例:

*輸入:

*5

*Online Judge

*Association for Computer Machinery

*Institute of Electrical and Electronics Engineers

*The Lord of the Rings

*netease

*輸出:

*OJ

*ACM

*IEEE

*LR

*N

*/

public class Abbreviation {

public static void main(String[] args) {

Scanner input=new Scanner(System.in);

int num=Integer.valueOf(input.nextLine());

String[] strArr=new String[num];

for (int i = 0; i < strArr.length; i++) {

strArr[i]=input.nextLine();

}

input.close();

for (int i = 0; i < strArr.length; i++) {

computer(strArr[i]);

}

}

public static void computer(String str)

{

String[] word=str.split(" ");

String tempStr="";

for (int i = 0; i < word.length; i++) {

tempStr+=getWord(word[i]);

}

System.out.println(tempStr);

}

public static String getWord(String str)

{

if(str.length()<3||"and".equals(str)||"for".equals(str)||

"the".equals(str)||"And".equals(str)||"For".equals(str)||"The".equals(str))

{

return"";

}

return str.substring(0, 1).toUpperCase();

}

}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/281782.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/281782.shtml
英文地址,請注明出處:http://en.pswp.cn/news/281782.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【C# Personal Handbook】運行環境

一、CLR、CLI、CTS、CLS、BCL、FCL簡介CLI&#xff08;公共語言基礎&#xff09;CLI是微軟公司向ECMA提交的一份語言和數據格式規范&#xff0c;CLR是目前為止唯一一個公共語言基礎的實現版本。CLI包括了公共類型系統&#xff08;CTS&#xff09;、公共中間語言&#xff08;CIL…

如何完善自己的知識結構

★領域 &#xff08;本來想用“學科”這個詞&#xff0c;后來覺得“學科”的范疇還是偏小&#xff0c;就改用“領域”&#xff09;  按照傳統的習慣&#xff0c;通常會把知識歸類到不同的領域&#xff08;比如&#xff1a;文學、數學、計算機、烹調、等等&#xff09;。 ◇領…

MATLAB編程與應用系列-關于MATLAB編程入門教程的總體編寫安排

本系列教程來源于出版設計《基于MATLAB編程基礎與典型應用書籍》&#xff0c;如涉及版權問題&#xff0c;請聯系&#xff1a;156204968qq.com。 出版社&#xff1a;人民郵電出版社&#xff0c; 頁數&#xff1a;525。 本系列教程目前基于MATLABR2006a&#xff0c;可能對于更高級…

python語言特性-------python2.7教程學習【廖雪峰版】(一)

開始學習廖雪峰的py2.7教程&#xff1a; 2017年6月5日12:54:28 筆記&#xff1a; 廖雪峰python2.7教程1.用任何編程語言來開發程序&#xff0c;都是為了讓計算機干活。 2.Python是一種相當高級的語言。代碼少還不好&#xff1f;代碼少的代價是運行速度慢。3.用Python可以做什么…

java調c++代碼_Java中調用C++代碼的實現 | 學步園

JNI為 Java Native Interface 即Java本地接口&#xff0c;使用此種方式可以對C/C代碼進行調用&#xff0c;其在本質上是對C/C生成的動態庫進行調用而不是直接對C/C代碼進行調用Java代碼如下&#xff1a;public class TestJNI{//JNI在本質上是調用C/C的動態庫來實現的&#xff…

jeesite1.X 集成多數據源

2019獨角獸企業重金招聘Python工程師標準>>> 網上看了幾個例子&#xff0c;都是相同數據源的動態切換&#xff0c;如果不是同一種數據庫類型&#xff0c;分頁查詢就出問題。經過研究解決問題。 jeesite.properties配置多數數據源地址,這里以mysql5.7和sqlserver2008…

k8s HPA(HorizontalPodAutoscaler)-自動水平伸縮

Horizontal Pod Autoscaling in Kubernetes寫在前面我們平時部署web服務&#xff0c;當服務壓力大撐不住的時候&#xff0c;我們會加機器(加錢)&#xff1b;一般沒有上容器編排是手動加的&#xff0c;臨時加的機器&#xff0c;臨時部署的服務還要改Nginx的配置&#xff0c;最后…

jQuery 基金會和 Dojo 基金會合并:Open Web

統一基金會&#xff0c;服務開發人員&#xff0c;推動開放 Web 技術發展jQuery 基金會和 Dojo 基金會今天宣布計劃聯合&#xff0c;旨在建立最大&#xff0c;最多樣化和最全面的基金會&#xff0c;通過服務開發者&#xff0c;他們的項目&#xff0c;他們的社區來構建開放的 Web…

spark java 邏輯回歸_邏輯回歸分類技術分享,使用Java和Spark區分垃圾郵件

原標題&#xff1a;邏輯回歸分類技術分享&#xff0c;使用Java和Spark區分垃圾郵件由于最近的工作原因&#xff0c;小鳥很久沒給大家分享技術了。今天小鳥就給大家介紹一種比較火的機器學習算法&#xff0c;邏輯回歸分類算法。回歸是一種監督式學習的方式&#xff0c;與分類類似…

jQuery.extend()方法

定義和用法jQuery.extend()函數用于將一個或多個對象的內容合并到目標對象。 注意&#xff1a; 1. 如果只為$.extend()指定了一個參數&#xff0c;則意味著參數target被省略。此時&#xff0c;target就是jQuery對象本身。通過這種方式&#xff0c;我們可以為全局對象jQuery添加…

1066. 圖像過濾(15)

原題: https://www.patest.cn/contests/pat-b-practise/1066 思路: 開胃小菜 實現: #include <stdio.h>int main (void) {int m;int n;int a;int b;int c;char ch;int tmp;int i;int j;scanf("%d %d %d %d %d", &m, &n, &a, &b, &c);// 題…

Wget用法、參數解釋的比較好的一個文章

一個語句就可以下載cvpr2016的全部論文&#xff1a; wget -c -N --no-clobber --convert-links --random-wait -r -p -E -e robotsoff -U mozilla http://www.cv-foundation.org/openaccess/CVPR2016.py 其中&#xff0c;-c表示斷點續傳&#xff1b;-N表示已經下載的內容不再重…

.NET VS智能提示漢化 (.Net6)

先上現成的.net6漢化文件&#xff0c;可以手動下載后參照 [如何為 .NET 安裝本地化的 IntelliSense 文件 ](https://learn.microsoft.com/zh-cn/dotnet/core/install/localized-intellisense)進行安裝。或者使用后文的工具進行自動安裝。無對照英文在前中文在前漢化內容來自 官…

go 返回mysql數組_Go基礎之--操作Mysql(一)

關于標準庫database/sqldatabase/sql是golang的標準庫之一&#xff0c;它提供了一系列接口方法&#xff0c;用于訪問關系數據庫。它并不會提供數據庫特有的方法&#xff0c;那些特有的方法交給數據庫驅動去實現。database/sql庫提供了一些type。這些類型對掌握它的用法非常重要…

Vue CLI 3開發中屏蔽煩人的EsLint錯誤

問題 Vue開發中&#xff0c;特別是當你閱讀分析別人的其中早期版本的Vue代碼時往往會遭遇到滿屏幕的煩人的EsLint錯誤。有關EsLint這個工具的作用不再贅述。查閱網上參考文檔&#xff0c;大多是針對早起版本Vue CLI工具項目的&#xff0c;在我最新使用的Vue CLI 3生成的工程中根…

pyinstaller---將py文件打包成exe

pyinstaller可將Python腳本打包成可執行程序&#xff0c;使在沒有Python環境的機器上運行。 1.pyinstaller在windows下的安裝 直接在命令行用pip安裝 pyinstaller&#xff0c; 在windows下&#xff0c;pyinstaller需要PyWin32的支持。當用pip安裝pyinstaller時未找到PyWin32&am…

老人尋求到一名程序員,用2W行代碼給自己打造了一幅肖像畫

今天翻墻看了下國外的論壇&#xff0c;看到了一位版主給一位老人描繪肖像畫的文章&#xff0c;不得不說這位大佬是真的厲害&#xff0c;近20000行代碼&#xff0c;而且還畫的很像&#xff0c;像小編我這種手殘黨&#xff0c;用筆也不能畫出來&#xff0c;不得不服&#xff0c;今…

一題多解,ASP.NET Core應用啟動初始化的N種方案[下篇]

[接上篇]“天下大勢&#xff0c;分久必合&#xff0c;合久必分”&#xff0c;ASP.NET應用通過GenericWebHostService這個承載服務被整合到基于IHostBuilder/IHost的服務承載系統中之后&#xff0c;也許微軟還是意識到Web應用和后臺服務的承載方式還是應該加以區分&#xff0c;于…

java jpa 模糊查詢_JPA 以SQL實現分頁不模糊查詢(參數可能為空)

repository代碼:package com.fancy.miniflow.repository;import java.util.List;import org.springframework.data.jpa.repository.JpaRepository;import org.springframework.data.jpa.repository.JpaSpecificationExecutor;import org.springframework.data.jpa.repository.Q…

GitHub服務中斷24小時11分鐘事故分析報告\n

上周&#xff0c;GitHub經歷了一次事故&#xff0c;導致服務降級24小時11分鐘。雖然平臺的某些部分不受事故影響&#xff0c;但仍然有多個內部系統受到了影響&#xff0c;向用戶顯示了過時且不一致的內容。所幸沒有用戶數據丟失&#xff0c;但針對幾秒鐘數據庫寫入的手動調整工…