此程序再加几句使他运行一次后,运行窗口出现"是否继续运行Y/N"该怎么办?

#include<stdio.h>
main()
{
int i,m=1;
char t;
printf("please input a number:\n");
scanf("%d",&i);
for(m=1;m<11;m++)
{
printf("%d*%d=%d",i,m,i*m);
printf(" ");
if(m%2= =0)
printf("\n");
}

HUX布斯
浏览 318回答 4
4回答

慕婉清6462132

使用前将 4 个 "`" 替换为一个 TAB 符#include <stdio.h>#include <stdlib.h>void main(void){````int i,m=1;````char t;````printf("please input a number:\n");````scanf("%d",&i);````for(m=1;m<11;m++)````{````````printf("%d*%d=%d",i,m,i*m);````````printf(" ");````````if(m%2= =0) printf("\n");````````````````printf("Continue or not?(Y/N) "); t = getch();````````while (t != 'y' && t != 'Y' && t != 'n' && t != 'N') t = getch();````````````````printf("%c", t);````````if (t == 'n' || t == 'N') break;````````printf("\n");````}}

扬帆大鱼

建议用C++编程,把scanf该为cin,就可以了:#include<iostream.h>void f(int i){int m;cout<<"please input a number:";cin>>i;for(m=1;m<11;m++){cout<<i<<"*"<<m<<"="<<i*m;cout<<" ";if(m%2==0)cout<<"\n";}}void main(){ int n,s;char t;f(n);cout<<"是否继续运行Y/N:";cin>>t;while(t!='N'&&t=='Y'){f(s);cout<<"是否继续运行Y/N:";cin>>t;}}

慕田峪4524236

main(){char c ;do{你的代码printf("是否继续Y/N");scanf(%c,&c)}while(c=="N"||c=="n");}

翻过高山走不出你

#include<stdio.h>main(){int i,m=1;char t,a;printf("输入循环条件!\n");a=getch()while(a!='n'){printf("please input a number:\n");scanf("%d",&i);for(m=1;m<11;m++){printf("%d*%d=%d",i,m,i*m);printf(" ");if(m%2= =0)printf("\n");}}输入N则停止
打开App,查看更多内容
随时随地看视频慕课网APP