#include <iostream>
using namespace std;
typedef struct PNODE{
int xs; int cs; PNODE *next;}pnode;
int CreateList(pnode* header,int n){
for(int i=1; i<=n; i++){ pnode *new_node = new pnode;//创建新节点 if (!new_node) { cout<<"创建失败"<<endl; return 0; }
new_node->next = nullptr; bool flag = true;//判断本次输入的数据是否已经存在相同次数项的标志 cout<<"请输入系数和次数:"; cin>> new_node->xs >> new_node->cs; pnode *s1 = header->next;
if (header->next==nullptr) { header->next = new_node; }
else { while(s1!=nullptr){//查找是否有相同次数的项 if(s1->cs==new_node->cs){//找到同次数的项 if(s1->xs+new_node->xs==0){//如果系数和为0 移除该节点 pnode *del = header->next; while (del->next!=s1){//找到前结点 del = del->next; } del->next = s1->next; delete s1,new_node; flag = false; break; }
else{//系数和不为0则 直接加 并且删除新节点 s1->xs += new_node->xs; delete s1,new_node; flag = false; break; } }else{//该项次数不同则找下一个结点 s1 = s1->next; } }
if(flag){//没有同次数项则 直接在对应位置插入新节点 //查找该结点的前驱和后驱 s1 = header->next;//s1保存前驱的位置 pnode *s2;//s2保存后驱 s2 = s1;//从首元结点开始查找 if (s1==nullptr){//如果还没有数据则直接填入 header->next = new_node; new_node->next = nullptr; delete s1,s2; }
else{ while(s2!=nullptr && s2->cs < new_node->cs){//找到第一个比该节点次数大的项 s1 = s2; s2 = s2->next; }//如果没找到s1应该为最后一项,s2为空 new_node->next = s2; s1->next = new_node; } } } } return 0; }
......................
阅读全部
|
田何义
贴于 2020年10月11日 23:53
hide
bbsi
int main (void)
static int a[3]=(0x11, 0x22, 0x33);int i,s=0,b[3];
for(i=0;i<3;i++)
s=s+alil;b(i)=s;
for (i=0;i<3;i++)
(
......................
阅读全部
|
shida
贴于 2020年9月28日 08:07
hide
bbsi
//辅助自定义代码生成器用
public void READSB()
{
string dir = AppDomain.CurrentDomain.BaseDirectory;
dir = dir + "READ\\";
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
string file = dir + "a.txt";
string file2 = dir + "b.txt";
......................
阅读全部
|
miaoge911015
贴于 2020年9月23日 18:30
hide
bbsi
#辅助自定义代码生成
SELECT DISTINCT
c.table_name,#表名称
c.column_name, #字段名称
c.column_comment, #字段注释
c.column_type, #字段类型
c.column_key,#是否主键
c.is_nullable#是否必填
,t.`TABLE_COMMENT`#表注释
FROM information_schema.columns c
LEFT JOIN information_schema.`TABLES` t
ON c.`TABLE_NAME`=t.`TABLE_NAME`
......................
阅读全部
|
miaoge911015
贴于 2020年9月23日 18:26
hide
bbsi
using System;
namespace bccn
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("随机编码");
Console.WriteLine();
// 练习一下随机编码的使用
......................
阅读全部
|
miaoge911015
贴于 2020年9月23日 18:08
hide
bbsi
#include<stdio.h>
int mian() {
struct stu{
char *name;
int num;
int age;
char group;
float score;
}stu1;
stu1.name = "Tom";
stu1.num = 12;
stu1 .age= 18;
......................
阅读全部
|
中山彭于晏
贴于 2020年9月20日 16:48
hide
bbsi
#include <stdio.h>
#include <iostream>
#include<string.h>
using namespace std;
int main(){
int n,i,j=0,sum,look[100];
char s[5];
for(i=0;i<6;i++)
std::cin >>s[i] ;
int cnt[256]={0};
for(i=0;i<6;i++){
cnt[s[i]]++;
......................
阅读全部
|
helloword123
贴于 2020年9月19日 20:18
hide
bbsi
#include<stdio.h>
void main()
{
int i,j;
scanf("%d",&i);
printf("%d",i);
}
阅读全部
|
kfx8421
贴于 2020年9月18日 08:33
hide
bbsi
#测试一个列表的for循环
#测试1
#深入的研究for循环你会发现,其实是程序每执行一次in后面的变量,并提取每次执行该变量中执行N次的字符位置。
zxc='a','b','c'
for i in zxc:
print(zxc)
#当打印in后面的变量时,print会显示出该变量的(字符所含有的总位数或元素数量*字符本身)
('a', 'b', 'c')
('a', 'b', 'c')
('a', 'b', 'c')
#因为是3个字符,所以打印3次,当打印变量i时,for语句是按zxc中的总元素数量来执行的,而每执行一次,就会提取其中第N个元素。
......................
阅读全部
|
qq935599717
贴于 2020年9月17日 04:50
hide
bbsi