| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 659 人关注过本帖
标题:[求助]求助几个问题~~~~~~~~~~~~
只看楼主 加入收藏
skyful
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2005-4-24
收藏
 问题点数:0 回复次数:9 
[求助]求助几个问题~~~~~~~~~~~~

1. 查找指定字符在字符串中第一次出现的位置,若找到则从该字符开始打印余下的字符串,找不到,则打印“Not Found”。

2. 从键盘输入若干字符,以符号“@”结束。编一个C程序统计这些符号的个数(不包括@),存入数组a[0],并将这些符号依次存入a[1]、a[2]、a[3]………中。接着利用a[0]中存放的字符个数,输出这些字符。

3. 编程实现从键盘为一个6×6 整型数组赋值,并将每一行的最小值和最大值显示出来。

4. 编程实现将一个用户从键盘临时输入的数插入到一个已排好序的数组中,插入后仍然有序。

5. Josephus问题描述如下:设有n个人围坐一圈,现从第s 个人(s<n)开始报数,数到 m(m<n)的人出列,然后从出列的下一个人重新开始报数,数到m的人出列,……如此反复,直到所有的人都出列。编写一个程序,解决Josephus问题:对于任意给定的n、s和m,输出其出列顺序。

那为大虾 帮帮我`~~~~~~~~~~~~~~

搜索更多相关主题的帖子: 字符 size 键盘 
2005-06-02 01:21
达达
Rank: 1
等 级:新手上路
帖 子:87
专家分:0
注 册:2005-5-26
收藏
得分:0 
小妹妹 这是不是老师布置的作业啊??
1  指定字符为 M
   int flag=1;
   for(i=0;a[i]=='\0';i++)
   {
       if(a[i]==M)  flag=1;
       if(flag) putchar(a[i]);
    }
    if(!flag) printf("Not Found\n");

要吃饭拉  先写一个把
以后再给你  哈?

2005-06-02 11:56
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2005-4-25
收藏
得分:0 
什么小妹妹 分明是个男的

/bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg');}" onmousewheel="return imgzoom(this);" alt="" /> 欢迎加入C语言QQ群698156 我们都是菜鸟乃至新手 坚信有一天定能展翅高飞 因为有着努力的决心 衷心盼望你的到来 让我们一起进步
2005-06-02 12:04
skyful
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2005-4-24
收藏
得分:0 
谢谢哥哥~~~~~~~~~~~~~~~能再把后面的搞定不!??

2005-06-02 12:17
musicml
Rank: 1
等 级:新手上路
帖 子:273
专家分:0
注 册:2005-4-2
收藏
得分:0 

/* 1. 查找指定字符在字符串中第一次出现的位置,若找到则从该字符开始打印余下的字符串,找不到, 则打印“Not Found”。

#include <stdio.h> #include <string.h>

#define MAXSIZE 100

int main(void) { char str[MAXSIZE]; char ch; int length; int i; puts("please enter the string:"); gets(str); puts("please enter the searching character:"); scanf("%c",&ch); length=strlen(str); for(i=0;i<length;i++) { if(str[i]==ch) break; } if(i==length) puts("Not Found!"); else for(;i<length;i++) printf("%c",str[i]); printf("\n"); return 0; } */

/*

2. 从键盘输入若干字符,以符号“@”结束。编一个C程序统计这些符号的个数(不包括@), 存入数组a[0],并将这些符号依次存入a[1]、a[2]、a[3]………中。接着利用a[0]中存放的字符个数, 输出这些字符。

#include <stdio.h> #include <string.h> #include <stdlib.h>

#define MAXSIZE 100

int main() { int length; char str[MAXSIZE]; char *a; int i; printf("please enter the characters which end with '@'.\n"); gets(str); length=strlen(str); a=(char *)malloc((length+1)*sizeof(char)); if(!a) exit(0); a[0]=length-1; for(i=1;i<length;i++) a[i]=str[i-1]; a[i]='\0'; for(i=1;i<=a[0];i++) printf("%c",a[i]); printf("\n"); return 0; } */

/* 3.编程实现从键盘为一个6×6 整型数组赋值,并将每一行的最小值和最大值显示出来。

#include <stdio.h>

int main() { int i; int j; int min; int max; int matr[6][6]; puts("please enter the maxtrix's number:"); for(i=0;i<6;i++) for(j=0;j<6;j++) scanf("%d",&matr[i][j]); for(i=0;i<6;i++) { min=matr[i][0]; max=matr[i][0]; for(j=0;j<6;j++) { if(matr[i][j]<min) min=matr[i][j]; if(matr[i][j]>max) max=matr[i][j]; } printf("The %d line's mininum and maxinum are %d and %d. \n",i+1,min,max); } return 0; } */

/* 4. 编程实现将一个用户从键盘临时输入的数插入到一个已排好序的数组中,插入后仍然有序。

#include <stdio.h> #include <stdlib.h>

int main() { int length; int *ip; int i; printf("please enter the length which is the initation arry's size:\n"); scanf("%d",&length); fflush(stdin); ip=(int *)malloc((length+1)*sizeof(int)); if(!ip) exit(0); printf("please enter the arry's result:\n"); for(i=0;i<length;i++) scanf("%d",ip+i);//不能对数组的名字进行运算 printf("the arry before sorting is as following:\n"); for(i=0;i<length;i++) printf("%4d",*(ip+i)); printf("\n"); void Sort(int*,int); Sort(ip,length); printf("the arry after sorting is as following:\n"); for(i=0;i<length;i++) printf("%4d",*(ip+i)); printf("\n"); printf("please enter the inserting number:\n"); scanf("%d",ip+length); Sort(ip,length+1); printf("the arry after sorting(with the inserted number) is as following:\n"); for(i=0;i<length+1;i++) printf("%4d",*(ip+i)); printf("\n"); return 0; }

void Sort(int * ip,int length) { int i; int j; int k; int temp; for(i=0;i<length;i++) { k=i; for(j=i+1;j<length;j++) if(*(ip+j)<*(ip+k)) k=j; if(k!=i) { temp=*(ip+k); *(ip+k)=*(ip+i); *(ip+i)=temp; } } } */


Every thing is possible.
2005-06-02 14:36
musicml
Rank: 1
等 级:新手上路
帖 子:273
专家分:0
注 册:2005-4-2
收藏
得分:0 

//Joseph(数组实现) //问题描述: //编号为1,2,...,n的n个人按顺时针方向围坐在一圈, //每个人持有一个密码(正整数)。一开始任选一个正整数作为报数上限值m,从第一个人 //开始按顺时针方向开始报数,报到m时停止报数.报m的人出列,将他的密码作为新的 //m值,从他的顺时针方向上的下一个人开始重新从1报数,如此下去,直到所有的人 //全部出列为止.

//作者:musicml

//程序如下:

#include <stdio.h> #include <conio.h> #include <stdlib.h> //定义Joseph的节点结构体 typedef struct josephnode { int joseph_num; int joseph_password; }joseph_node;

//输入各个结点信息的函数 void joseph_input(joseph_node arry[],int n,int *begin_num); //处理函数 void joseph_process(joseph_node arry[],int n,int *begin_num);

void main() { int total_pers; int begin_num=0; joseph_node * ip_jose; puts("please enter the total persons:"); scanf("%d",&total_pers); ip_jose=(joseph_node *)malloc((total_pers*sizeof(joseph_node))); if(!ip_jose) exit(1); joseph_input(ip_jose,total_pers,&begin_num); joseph_process(ip_jose,total_pers,&begin_num); }

void joseph_input(joseph_node arry[],int n,int *begin_num) { int i; int password; printf("please enter the begin password:\n"); scanf("%d",begin_num); for(i=0;i<n;i++) { printf("please enter th%d person's information:\n",i+1); printf("please enter the person's password:\n"); scanf("%d",&password); fflush(stdin); arry[i].joseph_num=i+1; arry[i].joseph_password=password; } }

void joseph_process(joseph_node arry[],int n,int *begin_num) { int ip; int counter=0; int total_num; int j; int count; int ip_node; int password; total_num=n; ip=0; password=*begin_num; //就一个结点的情形 if(total_num==1) { printf("th%d person out of the line is :\t",++counter); printf("%d\n",arry[0].joseph_num); exit(1); } //多个接点的情形 do{ count=0; do{ count++; ip_node=ip%total_num; ip++; }while(count<password); //输出出列的那个 printf("th%d person out of the line is :\t",++counter); printf("%d\n",arry[ip_node].joseph_num); //删除那个接点重新组合数组 password=arry[ip_node].joseph_password; ip=(ip-1)%total_num; total_num=total_num-1; for(j=ip;j<total_num;j++) { //arry[j].joseph_num=arry[j+1].joseph_num; //arry[j].joseph_password=arry[j+1].joseph_password; arry[j]=arry[j+1]; } }while(total_num>1); //最后一个接点输出 printf("th%d person out of the line is :\t",++counter); printf("%d\n",arry[0].joseph_num); }


Every thing is possible.
2005-06-02 14:37
musicml
Rank: 1
等 级:新手上路
帖 子:273
专家分:0
注 册:2005-4-2
收藏
得分:0 
好几天,都没编程了
随便写了下!!
至少可以满住你的要求!!!
自修去了~~~~~~~~[

Every thing is possible.
2005-06-02 14:40
skyful
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2005-4-24
收藏
得分:0 
谢谢了~~~~~~~~~~~~~~~~~~~~~~~~~~~

2005-06-02 16:42
skyful
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2005-4-24
收藏
得分:0 
4. 编程实现将一个用户从键盘临时输入的数插入到一个已排好序的数组中,插入后仍然有序。上面的这个题有问题啊!!!能不能再给一个能运行的啊~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~救命啊~~~~

2005-06-03 07:46
lwamani
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2004-11-16
收藏
得分:0 

First questiont: #include <iostream.h> #include <string.h> int Findchar(char c,char *p_char); void main(void) { int weizhi; char Ch[100]; char ch; cout<<"Please input a string:"; cin>>Ch; cout<<endl; cout<<"Please input a char:"; cin>>ch; weizhi=Findchar(ch,Ch); if(!weizhi) { cout<<"Can not find this char in this string!"<<endl; } else { for(weizhi;weizhi<strlen(Ch);weizhi++) { cout<<*(Ch+weizhi+1); } cout<<endl; }

} int Findchar(char c,char *p_char) { int biaozhi; int n=strlen(p_char); for(int i=0;i<n;i++) { if(c==*(p_char+i)) { biaozhi=i; break; } else { biaozhi=0; } }

return biaozhi; }


2005-06-03 11:32
快速回复:[求助]求助几个问题~~~~~~~~~~~~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017157 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved