首页 \ 问答 \ csdn java聊天室私人对话程序

csdn java聊天室私人对话程序

一个聊天室的程序,但是私聊怎么实现? 大多用的线程!
更新时间:2023-10-16 18:10

最满意答案

程序运行截图: 

1.单循环赛,是所有参加比赛的队均能相遇一次 
2.运动员类Sportsman 
3.运动项目类SportsEvents 
4.运动场地类PlayingField 
5.测试类

其他回答

public class josephus{
 public static void main(string[] args) {
 mandn(7,10);
 }
 public static void mandn(int m, int n) {
 circlelist cl = new circlelist(n);
 cl.showsequence(m);
 }
}
class circlelist{
 node head;
 circlelist(int n){
 head = new node(1);
 node tail = head;
 node temp;
 for(int i = 2;i <= n;i++){
 temp = new node(i);
 tail.setnext(temp);
 tail = temp;
 }
 tail.setnext(head);
 }
 public void showsequence(int m) {
 node temp = head;
 system.out.println("the sequence of getting out:");
 while(head != head.getnext()){
 for(int i = 0;i < m;i++)
 temp = temp.getnext();
 system.out.print(temp.getnumber() + " ");
 remove(temp);
 head = temp;
 }
 system.out.println(head.getnumber());
 }
 public void remove(node n){
 n.setnumber(n.getnext().getnumber());
 n.setnext(n.getnext().getnext());
 }
}
class node{
 private int i;
 private node next;
 node(int i){
 this.i = i;
 }
 public void setnumber(int i){
 this.i = i;
 }
 public void setnext(node next){
 this.next = next;
 }
 public int getnumber(){
 return i;
 }
 public node getnext(){
 return next;
 }
}

输出:
the sequence of getting out:
8 6 5 7 10 3 2 9 4 1

相关问答

更多
  • //定义接口IFruit public interface IFruit{ public String name="fruit"; public String getName(); //接口中的抽象方法 } //定义Farmer类用创建不同的实例对象 public class Farmer{ public void plant(IFruit fruit){ System.out.println("种植了:"+fruit.getName()); } } //Apple是实现IFruit接口 public cl ...
  • 程序运行截图: 1.单循环赛,是所有参加比赛的队均能相遇一次 2.运动员类Sportsman 3.运动项目类SportsEvents 4.运动场地类PlayingField 5.测试类
  • import java.util.Scanner; // 类名不要用中文,并且类名要和文件名保持一致 public class Test { public static void main (String[] agrs){ Scanner sc=new Scanner(System.in); System.out.println("请输入一个八进制的数"); String b=sc.nextLine(); // 这里写错了 // int q=Integer.valueOf("b",8); int q=Int ...
  • 求一段JAVA代码[2022-02-22]

    Image getImage(String filename){ URLClassLoader urlLoader=(URLClassLoader)this.getClass(). getClassLoader(); URL url=null; Image image=null; url=urlLoader.findResource(filename); image=Toolkit.getDefaultToolkit().getImage(url); MediaTracker mediatracker=ne ...
  • 本届WCA《魔兽争霸Ⅲ》项目的地图共有9张,分别是:   (2)Amazonia   (2)Ancientlsles   (2)BrightAndDark1.03   (2)DeathRoad1.2   (2)Echolsles   (2)LastRefuge-1.3   (3)Nomadlsles1.2   (4)TurtleRock   (4)TwistedMeadows
  • 你的逻辑有几个问题。 你想在一个while循环中把你的输入封装在仪表中,这样你就可以确保用户输入的仪表对于程序执行的其余部分是有效的。 剩下要做的就是用while语句而不是while循环将选项封装在while循环中。 通过这种方式,您可以选择一个选项,然后提示您在程序运行过程中尝试不同的转换,并且能够以您想要的任何顺序输入选项。 最后,将测量符号放置在输出旁边是非常有用的,因为当用户选择一个选项时,他们可以看到他们使用的转换公里数,“英寸和英尺”。 String inputString, inputOpti ...
  • 怎么了? stepTerm = (97ElementRowVector * 97by3Matrix).'; ? 在MATLAB上, clc N = 1e6; a = rand(1,97); B = rand(97,3); tic for ii = 1:N stepTerm0 = sum(bsxfun(@times, a.', B)).'; end toc tic for ii = 1:N stepTerm1 = (a*B).'; end toc max(abs(stepT ...
  • 应该大致在newarray之间(我假设你在每个循环之前创建一个新的数组),然后goto (如你所见,这会使控制流返回到前一行,因此循环): 第一个循环: 2: newarray int 4: astore_1 5: iconst_0 6: istore_2 7: iload_2 8: bipush 10 10: if_icmpge 23 13: aload_1 1 ...
  • 从threading 文档 : 如果您知道您调用的函数是基于编译的扩展,该扩展在其大部分计算期间释放Python全局解释器锁(GIL)...... 问题是在这种情况下,你不知道。 Python本身只允许一个线程同时运行(python解释器每次执行python操作时都会锁定GIL)。 如果myfun()将大部分时间花在编译的Python扩展中, 并且该扩展释放GIL ,则threading只会有用。 Parallel代码是如此令人尴尬地缓慢,因为你正在做大量的工作来创建多个线程 - 然后你无论如何只能一次执行 ...
  • 删除第二个循环,因为您可以一次打印三个值。 所以改变这个: while(prevprev) // from prevprev (i.e last 3rd element ) i m printing till null //i need to remove this loop and develop a logic in above loop? { // i am supposed to use single lo ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)