网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
02月05日漏签0天
c语言吧 关注:801,836贴子:4,376,022
  • 看贴

  • 图片

  • 吧主推荐

  • 视频

  • 游戏

  • 首页 上一页 11 12 13 14 15 16 17 18 19 下一页 尾页
  • 1465回复贴,共25页
  • ,跳到 页  
<<返回c语言吧
>0< 加载中...

回复:【教学贴】(二)新手学c的孩子们进吧,不定期回复

  • 只看楼主
  • 收藏

  • 回复
  • 未来chance
  • 异能力者
    6
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
void main()
{ int key,i=20,k=20,z=10,x=10,c=10,v=10;
for(;;)
{
c=i;
v=k;
key=getch();
if(key==72)
{ k=k-1;
}
printf("%d\n%d\n%d\n%d\n%d\n%d\n\n\n",z,x,c,v,i,k);
z=c;
x=v;
}
}
想不通为什么将if(key==72) 变成if(key>71)
{ k=k-1; { k=k-1;
同样按上键会有不同的结果,还有为什么按一次输出两次,
}


  • YUWENLOVE
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
你好!请问有没有数据库教程的视频网站?


2026-02-05 10:04:41
广告
不感兴趣
开通SVIP免广告
  • 御宅小受
  • 超能力者
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
不是回车就循环,是空格就输出,不是空格就ch+1输出。你输入的call me hal,都向后面推一个是dbll hf ibm,c后面是d,a后面是b,依次类推。
有人问我这个来着,好像是cpp的第七章的一个程序。那层应该是被百度吞了。


  • 未来chance
  • 异能力者
    6
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include<stdlib.h>
void Gotoxy(x,y);
void HideCursor();
void main()
{ int key,i=20,k=20,z,x,c,v;
for(;;)
{
c=i,v=k;
key=getch();
if(key==72)
{
Gotoxy(i,--k);
printf("●");
}
if(key==80)
{
Gotoxy(i,++k);
printf("●");
}
if(key==75)
{ i=i-2;
Gotoxy(i,k);
printf("●");
}
if(key==77)
{ i=i+2;
Gotoxy(i,k);
printf("●");
}
Gotoxy(z,v);
printf(" ");
z=c,x=v;
}
}
void Gotoxy(int x, int y) //移动光标
{
HANDLE hout; //定义句柄变量hout
COORD coord; //定义结构体coord
coord.X = x;
coord.Y = y;
hout = GetStdHandle(STD_OUTPUT_HANDLE); //获得标准输出(屏幕)句柄
SetConsoleCursorPosition(hout, coord); //移动光标
}
void HideCursor() //隐藏光标
{
CONSOLE_CURSOR_INFO cursor_info = {1, 0}; //后边的0代表光标不可见
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
接239楼,就是为什么不能控制两个点移动,只显示一个点移动


  • 未来chance
  • 异能力者
    6
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include<stdlib.h>
void Gotoxy(x,y);
void HideCursor();
void main()
{ int key,i=20,k=20,z,x,c,v,b,n;
for(;;)
{
c=i,v=k;
key=getch();
if(key==72)
{
Gotoxy(i,--k);
printf("●");
}
if(key==80)
{
Gotoxy(i,++k);
printf("●");
}
if(key==75)
{ i=i-2;
Gotoxy(i,k);
printf("●");
}
if(key==77)
{ i=i+2;
Gotoxy(i,k);
printf("●");
}
Gotoxy(b,n);
printf(" ");
b=z;n=x;
z=c,x=v;
}
}
void Gotoxy(int x, int y) //移动光标
{
HANDLE hout; //定义句柄变量hout
COORD coord; //定义结构体coord
coord.X = x;
coord.Y = y;
hout = GetStdHandle(STD_OUTPUT_HANDLE); //获得标准输出(屏幕)句柄
SetConsoleCursorPosition(hout, coord); //移动光标
}
void HideCursor() //隐藏光标
{
CONSOLE_CURSOR_INFO cursor_info = {1, 0}; //后边的0代表光标不可见
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
这是控制两个点移动的,而且只是写一个点,就是不明白z,x,c,v,b,n这些数据的赋值,为什么要在上面要多加b,n的赋值,去掉b,n就只能显示一个点,感谢楼主。


  • _诠释完美
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
【大整数取余,总是超时怎么改进一下?】求大牛帮帮忙
对于一个超大整数X(非负数),有n个数字b1,b2,……,bn作为X的基,基需要满足的条件是:
1) 1 < bi <= 1000 (1 <= i <= n),
2) gcd(bi,bj) = 1 (1 <= i,j <= n, i ≠ j).——GCD就是最大公约数啦~
题目大概就是:有T组测试样例,每组测试样例:
输入包括3行,第一行是基的个数n,第二行是n个基,第三行是超大整数X(X will be 400 or fewer characters in length)400位,需要用字符串处理。
输出:The output format is:(r1,r2,...,rn)——rn就是X%bn
样例输入
2
3
2 3 5
10
4
2 3 5 7
13
样例输出
(0,1,0)
(1,1,3,6)
下面是我的代码:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char x[401];
int X[401];
int MOD(char x[], int y) {
int i, l, t = 0;
l = strlen(x);
for (i = 0; i < l; i++) {
X[i] = x[i]-'0'; //把字符串x里的各个位的字符换成数字
}
for (i = 0; i < l; i++) {
t = (t*10+X[i])%y; //从第一位开始对基取余,然后乘10再取余,循环。
}
return (t);
}
int main(){
int T, n, i, a[101];
scanf("%d", &T);
for (; T > 0; T--) {
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]); //输入n个基
}
getchar(); //排除scanf最后的\0影响
gets(x); //输入大整数x(字符串格式)
printf("(");
for (i = 0; i < n-1; i++){
printf("%d,", MOD(x,a[i]));
}
printf("%d)\n", MOD(x,a[n-1]));
} //保证输出模式一致
return 0;
}
简单的测试都能过,但基太多就会超时


  • 王大锤
  • 麻婆豆腐
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
留名


  • 丨小丶波
  • 异能力者
    6
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
make


2026-02-05 09:58:41
广告
不感兴趣
开通SVIP免广告
  • 派大星的腹肌
  • 麻婆豆腐
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
马克


  • 可以叫你人渣么
  • 路人
    2
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
高一学生党,计算机竞赛正在学到c,上课听的时候能听懂,回家作业就不会了。。


  • _淡季s
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include<stdio.h>
#include<math.h>
void main()
{
int a,i;
float o[50];
for(a=2,i=1;a<=46;a++,i++)
{
o[i]=1.0*sqrt(a);
printf("%0.2d",o[i]);
if(i%5==4)
printf("\n");
}
}
帮我看看哪里错了


  • OpenVeye
  • 酱油
    4
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
楼主,看看这个程序,运行编译之后了,咋没输出结果呢
#include <stdio.h>
#include <math.h>
void main()
{void u0(float *p0);
void u1(float *p1,float x1[]);
void u2(float *p2,float x2[]);
void u3(float *p3,float x3[]);
void juzh(float *p4,float b[][5],float f1[],int n);
float x[5]={0.1,0.4,0.5,0.7,0.9};
float f[5]={0.61,0.92,0.99,1.52,2.03};
float a[4][5], a1[4][5];
float (*p)[5];
int i,j;
p=a;
u0(*p);
u1(*(p+1),x);
u2(*(p+2),x);
u3(*(p+3),x);
for(i=0;i<=3;i++)
{for(j=0;i<=4;j++)
a1[i][j]=a[i][j];
}
p=a;
for(j=0;j<=3;j++,p++)
{juzh(*p,a1,f,j);
}
for(i=0;i<=3;i++)
{for(j=0;i<=4;j++)
if(j%4==0)
printf("\n");
printf("%.6f",a[i][j]);
}
}
void u0(float *p0)
{int i;
for(i=0;i<=4;i++,p0++)
*p0=1;
}
void u1(float *p1,float x1[])
{int i;
for(i=0;i<=4;i++,p1++)
*p1=x1[i];
}
void u2(float *p2,float x2[])
{int i;
float x;
for(i=0;i<=4;i++,p2++)
{x=x2[i];
*p2=sin(x);
}
}
void u3(float *p3,float x3[])
{int i;
float x;
for(i=0;i<=4;i++,p3++)
{x=x3[i];
*p3=exp(x);
}
}
void juzh(float *p4,float b[][5],float f1[],int n)
{int i,j;
float sum1=0,sum2=0;
for(i=0;i<=3;i++,p4++)
{for(j=0;j<=4;j++)
{sum1=sum1+b[n][j]*b[i][j];
}
*p4=sum1;
}
for(i=0;i<=4;i++)
{sum2=sum2+b[n][i]*f1[i];
}
p4++;
*p4=sum2;
}


  • 崭不断翅膀
  • 大能力者
    8
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
楼主怎么学会编程 有时能看懂就是不会编


  • cqde11
  • 便当
    3
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include<stdio.h>
#include<stdlib.h>
#define ERROR 0
#define OVERFLOW -1
#define OK 1
#define NULL 0
#define maxqsize 100
typedef int elemtype;
typedef struct bitree
{
bitree *lchild;
bitree *rchild;
elemtype data;
}bitree;
typedef struct queue
{
int front,rear;
elemtype base[maxqsize];
}queue;
queue *initqueue();
int leverordertraverse(bitree *t);
bitree *creatbitree();
queue *enterqueue(queue *Q,bitree *p);
int printfbitree(bitree *p);
int queueempty(queue *Q);
int dequeue(queue *Q);
void main()
{bitree *t;
t=(bitree *)malloc(sizeof(bitree));
t=creatbitree();
leverordertraverse(t);
}
bitree *creatbitree()
{
bitree *t;
elemtype ch;
scanf("%d",&ch);
if(ch==0)
t=NULL;
else
{
if(!(t=(bitree *)malloc(sizeof(bitree))))
exit(OVERFLOW);
t->data=ch;
t->lchild=creatbitree();
t->rchild=creatbitree();
}
return t;
}
queue *initqueue()
{queue *Q;
Q=(queue *)malloc(sizeof(elemtype));
if(!Q->front)
exit(OVERFLOW);
Q->rear=0;
Q->front=Q->rear;
return Q;
}
queue *enterqueue(queue *Q,bitree *t)
{
if(!Q)
return ERROR;
Q->base[Q->rear]=t->data;
Q->rear=(Q->rear+1)%maxqsize;
return Q;
}
int queueempty(queue *Q)
{
if(Q->front==Q->rear)
return OK;
else
return ERROR;
}
int dequeue(queue *Q,elemtype e)
{
if(Q->front==Q->rear)
return ERROR;
e=Q->base[Q->front];
Q->front=(Q->front+1)%maxqsize;
return e;
}
int leverordertraverse(bitree *t)
{ queue *Q;
Q=(queue *)malloc(sizeof(elemtype));
char e=0;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Q=initqueue();
if(t!=NULL)
Q=enterqueue(Q,t);
while(!queueempty(Q))
{
printf("%d",dequeue(Q,e));
if(t->lchild)
Q=enterqueue(Q,t->lchild);
if(t->rchild)
Q=enterqueue(Q,t->rchild);
}
return OK;
}
楼主,我在最后一个//////////////////////////////后面就退不出程序,帮忙看看呗


2026-02-05 09:52:41
广告
不感兴趣
开通SVIP免广告
  • 克旋
  • 低能力者
    5
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
2437: English word
Time Limit: 1 Sec Memory Limit: 64 MB
Submit: 2352 Solved: 1137
Description
You still are worried about reading acm English problem, let me tell you a kind of very good method of Memorising Words, the root memory method,.the most interesting of the method is the prefix root. Now there are some English words to remembeand he knows some prefix root;He want to know how many words that can be remembered using each the prefix .in other words,how many words that contain the prefix ,Now to acmer you for help, can you help him?
Input
The input consists of T test cases. The number of them (T) is given on the first line of the input file. Each test case begins with a line containing a single integer number N that indicates the number of words (1 <= N <= 10000). Then exactly N lines follow, each containing a single word. Each word contains at least two and at most 10 lowercase characters, that means only letters 'a' through 'z' will appear in the word. The same word may appear several times in the list. Then follow a line containing a single integer number M that indicates the number of Words prefix question (0 <= M<= 10000). Then exactly M lines follow, each containing a single Words prefix.
Output
For the given input data, output exact M line, each line contain a ingle integer indicates the answer of each query.
Sample Input
1
4
preview
predict
premier
press
3
pre
press
pree
Sample Output
4
1
0
HINT
楼楼这道题不用指针能做么?要怎么做?这是我的代码,超时了。。。
#include<stdio.h>
#include<string.h>
int main()
{
int T,N,M,i,j,k,count,flag,e;
char a[10000][10],b[10000][10];
int c[10000];
scanf("%d",&T);
getchar();
scanf("%d",&N);
getchar();
for(e=1;e<=T;e++)
{
for(i=0;i<=N-1;i++)
{
gets(a[i]);
}
scanf("%d",&M);
getchar();
for(i=0;i<=M-1;i++)
{
gets(b[i]);
c[i]=strlen(b[i]);
}
for(i=0;i<=M-1;i++)
{
count=0;
for(k=0;k<=N-1;k++)
{
for(j=0;j<=c[i]-1;j++)
{
flag=0;
if(b[i][j]!=a[k][j])
{flag=1;break;}
}
if(flag==0)
{count++;}
}
printf("%d\n",count);
}
}
return 0;
}


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 首页 上一页 14 15 16 17 下一页 尾页
  • 1465回复贴,共25页
  • ,跳到 页  
<<返回c语言吧
分享到:
©2026 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示