Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Java calculate the number of characters

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "Java how to calculate the number of characters", the content of the explanation is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "Java how to calculate the number of characters" bar!

1. Topic description

Write a program that accepts a string of letters and numbers and spaces, and a character, and then outputs the number of characters in the input string. Case insensitive.

Enter a description:

Enter a string of letters and numbers and spaces, and a character.

Output description:

The number of characters in the output input string.

Input example:

ABCDEFA

Examples of output:

13. Code scheme 1

Basic idea: define String, Char variables-- through getline, cin input variables-- traverse the String array for comparison-- output count.

/ / suitable for any character input # include#include using namespace std; int main () {string inputString; char inputChar; getline (cin,inputString); / / getline reads characters from the standard input device and returns them to the input stream cin, where the data is bound to the variable inputString cin > > inputChar; / / scanf ("% c", & inputChar) / / the above are two ways of input: cin and scanf () int count=0; for (int item0

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report